Hello, please tell me the function of reading the arguments from the file line. The line contains two integer numbers separated by a space, the line is terminated by a newline character. How to count these two numbers into separate variables without using functions from the string library?

  • For functions of formatted reading of a stream in C ++, there is no concept of a "string". Therefore, if it is critical for you to "see" splitting into lines, then only getline and then manual parsing of the string. - AnT

2 answers 2

If the input stream is input , then

 int a, b; input >> a >> b; 

You can add to reset the input buffer

 input.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); 
     double s1,s2; ifstream fin(FILE_NAME, ios::in); fin >> s1 >>s2; 

    Pre-connect library