Hey all,
writing up some code to copy a string from a text file and extract numbers from the string. What I have so far is:
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[]){
ifstream in("test.txt");
if(!in){
cout << "Cannot open file.";
exit (1);
}
char str[255];
while(in){
in.getline(str, 255);
const string data = str;
int HEAD, DAY, MONTH, YEAR, HOUR;
HEAD = atoi( data.substr(0,4).c_str() );
DAY = atoi( data.substr(4,2).c_str() );
MONTH = atoi( data.substr(6,2).c_str() );
YEAR = atoi( data.substr(8,2).c_str() );
HOUR = atoi( data.substr(10,2).c_str() );
I am getting no errors but the program is not running. Does anyone have any ideas. Thanks in advance.
Colm