You should never ever use gets() because it will allow you to enter more characters then the buffer can hold, excess characters are just scribbled all over memory and your program will crash. There are a couple ways to avoid that problem
fgets() -- e.g. fgets(name, sizeof(name), stdin); The problem with fgets() is that it may append '\n' to the end of the string, which your program will have to remove. If '\n' is not present at the end of the string that means there are more keys in the keyboard buffer which your program needs to flush out.
scanf() -- e.g. scanf("%20s", name);
@ancient dragon will you please tell me that what is that problem of '\n' with fgets. i am not getting it from your answer. will you please explain it more . isn't scanf appends '\n' to the end ? please clearify me.
thanks in advance.
ancient dragon will you please tell me that what is that problem of '\n' with fgets. i am not getting it from your answer. will you please explain it more . isn't scanf appends '\n' to the end ? please clearify me.
Try it and see. You can't always rely on someone else to explain things to you, often a little test program is sufficient to answer your own questions.
'\n' ( 0x0D hex) represents the value of the Return key that you press on the keyboard. You should become familiar with the data found in ascii charts such as this one. Find 0D in the hex column then look in the Description column where you see "Carriage Return"
I Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...