----- Original Message ----- 
From: "John Matthews" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, June 08, 2008 6:16 PM
Subject: [c-prog] Re: input



What you need is something like:

char input[10 + 2]; /* creates an array of 12 chars */
fgets(input, sizeof input, stdin);

(It's better to use sizeof instead of '10 + 2' in the fgets because if
you change the size of the array, you don't have to remember to change
the fgets line.)

John

    Would it need to be char input[10+2] or input[10+1] since fgets adds \n. 
This I have read in my documentation. Whether or not fgets adds \0 or not I 
do not know my docs didn't specify but fgets returns NULL for error checking 
purposes. Tonight I will test with strlen and see if fgets adds \0.

Bill


Reply via email to