Answer to Question #208934 in C++ for faraz

Question #208934

Write a program to read numbers from a file.


1
Expert's answer
2021-06-20T18:14:15-0400
#include <iostream>
#include <fstream>
int main()
{
    // Load the file in a stream
    std::fstream file("nums.txt", std::ios_base::in);
    int a;
    // Read integer numbers from the file nums.txt
    while (file >> a)
    {
        printf("%d ", a);
    }
    getchar();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS