asdasd

cccc
Last edited on
line 13: file is undefined. Did you mean infile? BTW, this if statement is unnecessary. You haven't performed any operations on infile.

Line 14: You trying to open a file named file_nm. not the file name entered by the user. You don't test that this open succeeded.

Line 15: infile.eof is a function. () are required to call a function. Your test for eof() is in the wrong place. It should be after the getline.

Line 35: open takes a C-string, not a std::string.

Line 36: ENTRY is undefined. Did you intend txt?

Line 42: l is uninitialized. Result of the switch statement is undefined.





if (file.good()) You do not have any variable called file.

while(!infile.eof) there is no data member eof. There is member function eof() however.

getch(); You did not include header to use it. Anyway it is nonstandard and can simply be not supported by your compiler.

outfile.open(file_nm, std::ios_base::app); You might be using old compiler which not allows std::string as parameter. Use file_nm.c_str() instead.

outfile <<ENTRY; There is no variable ENTRY in your code.
Where have you declared a variable with the name of "file"?

Also you should be using the constructor to open your file.

1
2
3
4
5
ifstream infile(file_nm);
if(!infile)
{
   //file failed to open, do something.
}


Also the above code will only work if you are using a C++11 or later compiler.

And please find an use an indentation style you like, it'll make your program much easier to read.

Topic archived. No new replies allowed.