How to enter a line of data in C?

Joined
Jul 27, 2008
Messages
3
Reaction score
0
Hi

I have the code
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top