Thread: reading file
hello !
can read file in c++ don't know how read between 2 points
read whole file
what logic stop reading file when program finds -1 character? if not want write down code show me logichtml code:string string; ifstream infile; infile.open("file"); while(!infile.eof()) { getline(infile,string); cout<<string <<endl; }
in advance.
something should (i didn't test program, give logic)
basic idea can overload ">>" operator take in formatted input.also, using getline, reading whole line @ time, , not single word string.code:string string; ifstream infile; infile.open("file"); while(!infile.eof() || string!="-l" ) { infile>>string; cout<<string <<endl; }
also, looking "string" or "character"? not same in c++. string array of char variables.if looking character (i.e. char variable), read 1 character @ time defining character instead of string.
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk reading file
Ubuntu
Comments
Post a Comment