NO

Author Topic: "Console Program Output" problem  (Read 1824 times)

manolojohny

  • Guest
"Console Program Output" problem
« on: January 09, 2012, 05:33:16 pm »
//exercise 1
#include<stdio.h>
struct cars
{
        char manufacturer[20],model[20];
        int engine_cc,year,cost;
}x[1];
void printcars();
int main()
{
int i;
for (i=0; i<=1; i++)
{
        printf("Insert cc of the engine,year of manufacture,cost,the manufacturer and the model of the car...\n");
        scanf("%d%d%d",&x.engine_cc,&x.year,&x.cost);
        fflush(stdin);
        scanf("%s",&x.manufacturer);
        fflush(stdin);
        scanf("%s",&x.model);
        fflush(stdin);
        printf("next car:\n");
}
printcars(x);
}

void printcars()
{
int i;
for (i=0; i<=1; i++)
{
        printf("Car[%d]:\nmanufacturer:%c\nmodel:%c\nengine:%d\nyear:%d\ncost:%d\n\n",i,x.manufacturer,x.model,x.engine_cc,x.year,x.cost);

}
}

For some reason I don't know when I execute this,the "console program output" window stops working after I insert the model of the second time!
there is also a message that says "exercise 1.exe has stopped working"

could you please tell me what's going on?

czerny

  • Guest
Re: "Console Program Output" problem
« Reply #1 on: January 09, 2012, 06:37:49 pm »
You havn't done this with Pelles C? Right?

czerny

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 754
Re: "Console Program Output" problem
« Reply #2 on: January 09, 2012, 07:32:12 pm »
For some reason I don't know when I execute this,the "console program output" window stops working after I insert the model of the second time!
there is also a message that says "exercise 1.exe has stopped working"

could you please tell me what's going on?
Well, beside that the program as you posted it doesn't compile in Pelle's C, which probably is the reason why czerny posted his reply, the program rather seems to do exactly what you programmed to do.

Both the input and the output (printcars() ) run for exactly 2 loops...

Ralf

CommonTater

  • Guest
Re: "Console Program Output" problem
« Reply #3 on: January 09, 2012, 11:37:15 pm »
There are too many problems with the program itself to tell if there is any reportable bug in Pelles C, here.

You need to sort out your own code before you make bug reports...

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 754
Re: "Console Program Output" problem
« Reply #4 on: January 10, 2012, 03:07:57 am »
There are too many problems with the program itself to tell if there is any reportable bug in Pelles C, here.

You need to sort out your own code before you make bug reports...
Oops, didn't even realize that this was posted in the "Bug reports" section. A moderator should move this thread into the beginners section instead... ???

Ralf