Arrays Introduction

  • + 0 comments

    The firts while loop finishes when cin reads EOF, i.e. when cin finishes to read the whole input stream.

    Another way is using scanf from C, it returns the number of input data assigned or the defined macro EOF (-1) when there is nothing less to read, so you can do the next one:

    while(scanf("%i",&A[i++])>0);
    //or
    while(~scanf("%i",&A[i++]));
    

    Those are the way of reading in c++ the whole input, there is challenges where the input size is not given

    Sorry my english.