...

View Full Version : How to enter a line of data in C?



Advancedkill
07-30-2008, 09:23 PM
Hi

I have the code


printf("Enter the characters:\n");
char enc_numbers[10]; //Read in characters
gets(enc_numbers);


Which I am using to read in a line of characters between 1 and 10 (inclusive) characters long. However, if I put this under a previous line using scanf it doesn't work (I'm using scanf to get a single inputted number, which always works).

I heard that using gets is bad - is this true and how should I read in a line of characters where I don't know how many are going to be entered?

Thanks

abduraooft
07-31-2008, 04:32 PM
See http://www.c-faq.com/stdio/scanfinterlace.html
http://c-faq.com/stdio/getsvsfgets.html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum