it doesn't give me syntax error but compile error... i notice it's from my for loop "specifically the do to input a name " i want to know how i can fix this problem in my do if anyone can help me..
Code:
#include <stdio.h>
// This program is a structure which in structure task im doing in class
//THe problem i see in this program lies which in the do loop
//this program suppose to record the names of people and their date, and time..
/*structure of date*/
struct date
{
int year;
int month;
int day;
};
/*structure of time*/
struct time
{ int hour;
int minute;
int second;
};
/*structure of the records*/
struct record
{ char Names[30];
};
/*structures with structures inside of it*/
struct info
{ struct date record1[30];
struct time record2[30];
struct record people[30];
};
int main(void)
{
struct info event;
int temp,num,i,x=0;
char letter;
printf("How many people would u wish to log?\n");
scanf("%d",&num);
if( num > 30){
printf("ERROR\n");
printf("How many people would u wish to log?\n");
scanf("%d",&num); }
for( i = 0; i < num; ++ i)
{
/* the do is my primary problem in this program*/
do
{
printf("Enter name\n");
letter = getchar();
event.people[i].Names[x] = letter;
++x;
}while(letter != '\n');
event.people[i].Names[x-1] = '\0';
printf("Enter year\n");
scanf("%d",&temp);
event.record1[i].year = temp;
printf("Enter month\n");
scanf("%d",&temp);
event.record1[i].month = temp;
printf("Enter day\n");
scanf("%d",&temp);
event.record1[i].day = temp;
printf("------------------------------\n");
printf("NOW ENTER THE hour!!!!!\n");
scanf("%d",&temp);
event.record2[i].hour = temp;
printf("ENTER MINUTES!!!!!!\n");
scanf("%d",&temp);
event.record2[i].minute = temp;
printf("ENTER SECONDS!!!!\n");
scanf("%d",&temp);
event.record2[i].second = temp;
printf("%s",event.people[i].Names);
}
getchar();
}