1
0
Fork 0
This repository has been archived on 2021-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
uni-m.cds-adv-prog/ex5.2/main.cpp

36 lines
498 B
C++

#include <fstream>
#include <iostream>
int main() {
std::ifstream fh("data1.txt");
if ( fh ) {
std::cout << "File opened OK" << std::endl;
}
else
{
std::cout << "Opening File Failed" << std::endl;
return 1;
}
int number ;
while(fh >> number) {
if ( number == 0 ) {
std::cout << "Found a Zero: Breaking Loop" << std::endl;
break;
}
std::cout << "Found number: " << number << std::endl;
if ( fh.eof() ) {
std::cout << "EOF" << std::endl;
break;
}
}
}