Hello,
I need to prompt the user for a filename and then open and read from that file. Also I need to be able to take the contents of the file I'm reading from and store them in a vector or stack.
This is the code that I have so far but I don't know if this is the most efficient way to do it or why it doesn't seem to be working.
The file to be opened is a simple text file containing a series of integers in this fashion.Code:string file_name; cout<<"What is the name of the maze input file?"<<endl; getline(cin, file_name); char c_file[20]; int i = 0; while(file_name[i]!=0) //I convert the string into an array of chars because //the open function only accepts char arrays as a { //paremeter c_file[i]=file_name[i]; i++; } fstream read_file; read_file.open(c_file);
From here I can't figure out how to actually pull information out of the file efficiently.Code:9 890000088 888888088 888888088 800088088 808008088 808000088 808800888 000008888 888818888
Thank you for any help.



LinkBack URL
About LinkBacks



