fileinputstream - C++ File Input 3 ints on line reading -
so have file c++ reading in. has 3 ints 4 4 16 looks that. i'm curious how go getting read 3 variables have cars carcapacity people
i have set 2 different ways of trying them neither working. infinite loop
fin >> cars >> carcapacity >> people; 1 way i'm trying store input. was:
fin >> cars;
fin >> carcapacity
fin >> people
i'm using ifstream file, check make sure there file , use while(!fin.eof()) loop entire txt file. appreciated. in advance!
the easiest way use "freeopen"
file: a.txt 1 2 3 #include <iostream> #include <stdio.h> using namespace std; int main(){ freeopen("a.txt", "r", stdin); int a, b, c; std::cin >> >> b >> c; std::cout << << b << c; } p/s: don't test
Comments
Post a Comment