Write a program to read numbers from a file.
#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;
}
Comments
Leave a comment