0

I'm new to C language and I'm trying to make a program that includes an array of type int with the max length of 10. I want to enter a random number of 1-digit numbers and set all the other values to 0. For example, the console will look like this:

Enter B Values : 1 2 5 7 8

and the B array will look like this 1 2 5 7 8 0 0 0 0 0

I'm trying to add the numbers at the same line without using Enter. Could anyone help? Could the answer be EOF related?

  • Do you mean you don't want to hit Enter just between the elements, or that you don't want to hit Enter even at the end? – Joseph Sible-Reinstate Monica Apr 26 '20 at 18:49
  • @KunalMukherjee Not really, I'm limited to the beginner's functions, such as scanf and EOF and array – AndyBrondy7 Apr 26 '20 at 18:52
  • 1
    Yes, I dont want to hit enter just between the elements and after I'm finished with filling, I have to press Enter only at the end – AndyBrondy7 Apr 26 '20 at 18:54
  • Not really, I'm limited to the basic way of reading input, by scanf, – AndyBrondy7 Apr 26 '20 at 19:16
  • The input may not even reach your program before you hit `Enter`, it may be buffered in the terminal emulator. On Linux, you can use Ctrl+D to flush it, but note that flushing empty buffer will be treated as EOF. – numzero Apr 26 '20 at 19:58

0 Answers0