Hi,
I am so happy to find this forum. I am new to all this and I have a question.
Yes I am doing homework and the problem requires me to open a txt.file and put test answers into a parallel array and then manipulate it a bit figuring out score, average ect.
I don't want code for that, I have written the manipulation function bits already and I think it'll work but I can't for the life of me get the info out of the file and into the array and I can't figure out what I'm doing wrong.
So.. I wrote a little program to try and figure out how the whole i/o file /array thing works but I'm stuck. In fact I've written it more than a few times and none of them work. I looked in the FAQ and did a search but didn't really see anything that helped. I think maybe my question is maybe too basic and something most folks already know.
Any suggestions would be appreciated however I'm really hoping someone can tell me "why" it works the way it works so I will never have to ask again and so I have a better understanding of what I'm doing.
My professor says we should have had this last term and I got a good grade last term but we didn't do any programs that involved files and so I'm playing catch up and I am really confused.
Thanks for any help here's one of my attempts
Code:
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
main ()
{
ifstream fileInput; //input file variable
ofstream fileOutput; //output file variable
char answers[][25]; //array for holding answers
fileInput.open("filename", ios::in);
fileOutput.open("filename", ios::out);
getline(fileInput, answers[][20]);
fileInput.ignore(4, '\n') //because i need to ignore the first
//4 chars in my big program
fileInput.close();
fileOutput.close();
return 0;
}