arrays - How do I use scanf when I dont know how many values it will assign in C? -


These instructions are: "Read the letters from the standard input until the EOF (file off mark mark) is read.

Then the user will enter the characters, but I do not know how many

should not be allowed to enter text - as soon as the program starts, read the data. "

How should I go about this?

This is my opinion

This is my idea

 int main (zero) {int inputlist [], i = -1 ; {{++ i; Scanf ("% f", and input list [i]);} while (input list [i]! = EOF)  

You said that the character Therefore it can be used

  four axis [10000]; Ch = getchar (); While (ch! = EOF) {arr [i ++] = ch; Ch = getchar (); } // arr [i] = 0; To make this a string, if necessary  

and to convert to ASCII

 for  (j = 0; j & lt; i ; J ++) printf ("% d \ n", arr [j]]);  

If you use an integer array, then use

  int arr [1000]; While (scanf ("% d", & amp; arrival [i ++]) = EOF!);  

PPS: This works only when your input is one letter per line.

scanf returns EOF at EOF


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -