Hi everyone!
I'm triyng to develop a program whith this functions:
1 - Read data from text file
2 - Put the data from file to a variable(ignoring comments in the file)
3 - Tokenize the data e transform the variable into another variable(like float)
4 - Make the calcs and put the data in another variable.
5 - Write the variable in another file
I'm look in various treads,site,books but I don't find especific what i'm look for.I make some progress:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<fstream.h>
#include<iostream>
using namespace std;
int main () {
char c, str[3];
ifstream is;
cout << "Enter the name of an existing text file: ";
cin.get (str,256);
is.open (str); // open file
while (is.good()) // loop while extraction from file is possible
{
c = is.get(); // get character from file
if (is.good())
cout << c;
}
is.close(); // close file
getch();
return 0;
}
This code read the imput text file and write in the screen the values, but I wanna tokenize/split this values, and transform then into float(once they are char).
The file I read is this:
#S 1
1 50 30 25 68
I wanna compare the #S 1 to another value pre-determined, and tokenize the value in the down line...
Can you help me?
Thanks and Sorry my english =]