Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Need Help (http://www.go4expert.com/forums/need-help-t8057/)

bashamsc 1Jan2008 12:07

Need Help
Suppose i have a file in which i have strings and integers

I want read that file and wants to store in an array.

My problem is how to differciate whether the read one is string or integer.

Because i need to manupulate the data .

technosavvy 2Jan2008 17:46

Re: Need Help
if the file you are reading only contains strings and numbers then u can easily do it...(i.e. there are no alphanumeric words in the file)

in this case
1) read every word from the file as a string ...
2) convert the string into a number using atof
3) if the input is a string the return value of the function atof is 0 otherwise the return value will be
the number converted.
4) put a check in your program for the return value of the function and you are done

bashamsc 2Jan2008 22:24

Re: Need Help
I want in c++ not in c.

technosavvy 3Jan2008 10:00

Re: Need Help
even if u want in C++ ...atof will work ...

do u have any other issue..do let me know ..

All times are GMT +5.5. The time now is 00:15.