I been reading some c programing tutorials in the web but so far i have nto found any good tutorial that is for a begginer.
I am having trouble with the following program im trying to put together:
/* This is a program i created by my self*/
#include <stdio.h>
main()
{
int person_fname;
int person_age;
/*long int my_age;*/
printf("This program will tell you if you are older or younger than the programer\n");
printf("Please enter your first name and press [Return]\n");
scanf("%c", &person_fname);
getchar();
printf("Now please enter your Age and press [Return]\n");
scanf("%c", &person_age);
getchar();
printf("Very well now i know that your name is %c and that you are %c old\n", person_fname, person_age);
getchar();
}
Here is the problem when I compile and run the program, if I type more then one character the program crashes. am I putting the wrong data type for my variables? This is my first time trying to learn how to program I have read everything I been able to put my hands on but none of the tutorials out there are very noob friendly, to some degree they expect you to know some coding ect ect.
Thanks in advance for any help.
I am having trouble with the following program im trying to put together:
/* This is a program i created by my self*/
#include <stdio.h>
main()
{
int person_fname;
int person_age;
/*long int my_age;*/
printf("This program will tell you if you are older or younger than the programer\n");
printf("Please enter your first name and press [Return]\n");
scanf("%c", &person_fname);
getchar();
printf("Now please enter your Age and press [Return]\n");
scanf("%c", &person_age);
getchar();
printf("Very well now i know that your name is %c and that you are %c old\n", person_fname, person_age);
getchar();
}
Here is the problem when I compile and run the program, if I type more then one character the program crashes. am I putting the wrong data type for my variables? This is my first time trying to learn how to program I have read everything I been able to put my hands on but none of the tutorials out there are very noob friendly, to some degree they expect you to know some coding ect ect.
Thanks in advance for any help.