//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?