You are here:

C++/file handling

Advertisement


Question
how to read line by line from a text file and differentiate between charecter data and integer data present in the line.

Answer
dear harsha !

Here i give some idea's or tech's to do that!

1. Read a data file in terms of charecters.
2. You know how to differentiate a word from line !
  ( a word may be separated from a line at each encounter of  
    space  , ;  ,  ... )
  device an algorithm in such a way it will read words insted of lines from a text file

3. convert the word using integer using atoi() function  ,
  if the function converts the given word  structure into unteger then its a valid integer  , else its a string.
4. Using this method you can easily differentiate integer and text from a text file .

Try it surely it will work

regards
Prince M . Premnath.

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Prince M. Premnath

Expertise

Years of research in C/C++ Will bring you all facts regarding , OOPS , SVGA , MOUSE , BIOS , IVT , Feel free to query me :-)

Experience

More than 5 years

Education/Credentials
MCA

©2016 About.com. All rights reserved.