Simple text file reading

I want to read text file(.txt) line by line in c++.
each line contains instructions like

copy(m,n)
inc(n)

this instruction can be of many times. if instruction is wrong, it throws exception.

No switch case.
Hi.
Excuse me, I didn't understand your question exactly.
But if you want to read a file line by line, you can use getline() in cstring.h
1
2
3
4
5
6
7
8
9
#include <cstring.h>
#include <fstream.h>

int main()
{
   fstream file("FilePath", ios::in);
   string str;
   getline(file, str); // <- This line read a line of file and put it in a string object
}
Topic archived. No new replies allowed.