| | |
Not reading in entire file.
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
I just can't figure out why this program isn't reading in the entire file. It will only read in the second line, nothing else.
Here are my read and write functions:
bool Write(string Text,string FileName){
fstream Write;
Write.open(FileName.c_str(),ios::out|ios::app);
if(!Write){
cout<<"Error in opening file";
return 0;
}
Write<<Text;
Write.close();
return 1;
}
void Read(string FileName){
char buffer[300];
fstream Read;
Read.open(FileName.c_str(),ios::in);
Read.seekg(0,ios::beg);
while(!Read.eof()) Read.getline(buffer,300);
cout<<buffer;
Read.close();
}
Thanks for your time,
Squirrel Prodigy
Here are my read and write functions:
bool Write(string Text,string FileName){
fstream Write;
Write.open(FileName.c_str(),ios::out|ios::app);
if(!Write){
cout<<"Error in opening file";
return 0;
}
Write<<Text;
Write.close();
return 1;
}
void Read(string FileName){
char buffer[300];
fstream Read;
Read.open(FileName.c_str(),ios::in);
Read.seekg(0,ios::beg);
while(!Read.eof()) Read.getline(buffer,300);
cout<<buffer;
Read.close();
}
Thanks for your time,
Squirrel Prodigy
![]() |
Similar Threads
- Reading in a text file -- efficiently (Java)
- Help reading data from a file (C++)
- C++ Reading from a text file (C++)
- CSV file (C)
- assignment help [fstream, on modifying a record in a file] (C++)
- Reading an input file as a class memeber function (C++)
- reading txt file into array (C++)
Other Threads in the C++ Forum
- Previous Thread: a little prob with TIME
- Next Thread: 2 errors in c++ program :-(
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker list loop looping loops map math memory multiple news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference rpg sorting string strings struct temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





