{
            cout <<" file found ..." << endl;
                while((ch = infile.get()) !=' ' )
		{
		 cout <<"\nRead value is : "<< ch<<endl;
		 cout << "calling function : ";
		 populateArray(ch, i);
		 }
      }

file contents : if ( a + b ) ;

basically its taking the file pointer and taking a char, until it gets to a space. it works fine but is there anyway of telling it to carry on after the space? At the moment it gets if and then nothing else. I need it to stop at a whitespace put it into a buffer ( hence the function - for playing about with) then carrying on...

Any ideas?

cheers
John

Recommended Answers

All 3 Replies

Loop until you find an EOF. Something like this?

while((ch = infile.get()) != eof )
		{
                         if ( ch != space )
                         {
                		 cout <<"\nRead value is : "<< ch<<endl;
	        	         cout << "calling function : ";
	                	 populateArray(ch, i);
                          } 
		 }

infile >> ch;

oops ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.