The text document is TTT.txt ...in it is
X X X O - X O O -
I need my program to read each and then be able to pass it to a dif开发者_运维技巧ferent part of it...HELP!
char stuff[9];
FILE* foo = fopen("myfile.txt", "r");
for (int i = 0; i < 9; i++) {
stuff[i] = fgetc(foo);
fgetc(foo); // Ignore the newline
} // Now your characters are in "stuff"
No error handling, hardcoded file name, and uses C functions. But it does what you want in a concise format.
Since this is homework, I'm not going to post actual code. but I'll give you a hint into the right direction.
What you need is file streams. You can read from a file using std::ifstream. It has several methods of reading. The one your looking for is probably operator >> reading into a char.
Read up on it, try to start off, and come back here when you get stuck, showing us what you have done so far and why you got stuck.
加载中,请稍侯......
精彩评论