I have a txt file with numbers like 541399.531 261032.266 16.660 (first line) 541400.288 261032.284 16.642 (2nd line)........hundred of points. i want to convert this file i
Look for the stl classes istringstream and ofstream. The first one to automatically convert strings to doubles, the second one to have binary file output. In the example instream is an istringstream and os is an ofstream, the latter opened with the correct mode (ios_base::binary | ios_base::out).
while (getline(cin, s)) {
instream.clear(); // Reset from possible previous errors.
instream.str(s); // Use s as source of input.
if (instream >> myDouble)
os << myDouble;
}