Well, all I know is that I hate not having practical application (I'm the same as you are when it comes to learning). However, I found another tutorial that is much better at explaining at howstuffworks.com. It's kinda cool, actually. It also gives you ideas on how to try to manipulate the code to get better at it. I suppose my main question now is what am I doing wrong? I'm writing my first simple program completely on my own (sort of as a homework thing to myself) to try to better understand what's going on with the code (the functionality of it and such). Anyway...this is what I have so far...
Code:
#include <stdio.h>
int main()
{
int a;
char b;
{
printf("Please enter your age: ");
getchar();
scanf("%d", &a);
printf("Please enter the first letter of your first name: ");
getchar();
scanf("%c", &b);
printf("Thank you, %c. Have a great day. You're %d years old!", b, a);
getchar();
scanf("%c, %d", &b, &a);
}
return 0;
}
Anyway, my program is meant to basically allow user input and then repeats what the put in with the last printf statement. The problem is apparant when I run the program. It goes along fine until the end when it says "Thank you, G. Have a great day. You're 0 years old!". Even though I enter in 20 as the age, it still says 0 and I can't seem to figure out why. Any help would be much appreciated. Thanks.
-Gavin
PS Thanks for the previous advice/information.