Skip to main content

Thread: reading file


hello !

can read file in c++ don't know how read between 2 points

read whole file

html code:
string string;  ifstream infile;  infile.open("file");    while(!infile.eof())  {             getline(infile,string);             cout<<string <<endl;  }
what logic stop reading file when program finds -1 character? if not want write down code show me logic

in advance.

something should (i didn't test program, give logic)

code:
string string; ifstream infile; infile.open("file");  while(!infile.eof() || string!="-l" ) {            infile>>string;               cout<<string <<endl; }
basic idea can overload ">>" operator take in formatted input.also, using getline, reading whole line @ time, , not single word string.

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

Popular posts from this blog

Thread: gpg: Conflicting Commands

Adobe Acrobat Pro , Terminal Server Use

when i try using AE CC 3d camera tracker after the first step it says "Analysis solve failed." help?