Monday, May 24, 2010

Reading files in C++?

I have to read in some text files, and stores the data into a vector and matrix, and then writes the information in the vector and finds the average of the matrix in a new text file. I have no clue where to start, do you have any ideas of how to approach this problem? Thanks.

Reading files in C++?
#include %26lt;fstream%26gt;


............


using namespace std;





int main(){


........


//other defination





char *filename;


//the file name(path?) that u wanna read





ifstream instream;


//define a instream to let the file in





char buffer[1024];


//define a buffer to receive the context





instream.open(filename,ios::in);


//now open the file





filestream.read(buffin,sizeof(buffin));


//Read the context and store it into a buffer(an array in char)





........


//now u can do something to send the data in the array to the vector





//for more help and details u can find in MSDN Library


........


return 0;


}

song words

No comments:

Post a Comment