Little question from newbie(
Could someone help, im at very beggining of learning programming, but already faced issue, at very start)
When i do some practice tasks for begginers i wrote a program like this :
int main()
{
char name[50], town[50];
int age;
printf("Hi, what`s your name? ");
gets(name);
printf("\nWelcome to our show, %s\n", name);
printf("\nHow old are you?");
scanf("%d", &age);
printf("\nHmm, you don`t look a day over 22\n");
printf("\nTell me, %s, where do you live?\n", name);
gets(town);
printf("Oh, i`ve heard %s is a lovely place", town);
return 0;
...but unfortunately, this program breaks at the point where second gets(town) appeared, and doesn't let me enter the name of town.. I couldn't figured out why? seems like everything ok for me...:(
I will be really appreciate for help!
here the simple of program from this handbook, but its works properly, it looks lke there no any differences between
char customer[30], acctNum[30];
double avgBalance, interest, service;
int numTrans;
printf("Name? ");
gets(customer);
printf("Account number? ");
gets(acctNum);
printf("Average balance? ");
scanf("%lf", &avgBalance);
printf("Number of transactions? ");
scanf("%d", &numTrans);
interest = avgBalance * 0.06; service = numTrans * 0.50;
printf("\nName: %s\n", customer);
printf("Average balance: $%3.2f\n", avgBalance);
printf("Interest: $%3.2f\n", interest);
printf("Service charge: $%3.2f\n", service)