can anyone give me the idea how can i sort out the data types from a text file. let suppose i have a txt file contain
----txt file---------
256 horse
-569 elements
1.256 GPA
32777 Cars
A Grade
-------end -----
i want to store integers in seprate variables of int type let suppose an int array. and stings in some char array. double in double type array and so on. i mean i want to sort the data from that file. please give me any help or ideas . i shall be thanks full to you all
i am new in C++ my knowledge about file stream as under
i know basics of opening txt file read and wrtie data from it. seekp() seekg() and tellp tellg fucntions. and all ios:: directives.
the above text file i showed was an example i want to clear the concept about sorting of any text file of any data. i want to store all data in their respective types.
did't understand , you mean to initialize all type of arrays like int double char etc then read the file with delimiter, but how can reader sort the type into correct array? means if i read this line
256 cars
how can reader put 256 into int array and cars into char?
let me clear you that i don't know what the txt file have in it.
there might be this line
256 cars
or might be
cars 256
we don't know the orders of words which come first. i want to get an idea how the file-reader justify which type of word he is reading and in which data type he needs to store it