Once you know where the first space char is, you can copy all the chars prior to that into your string array, and the converted int to your int array
i tried this, but it gives me errors.
Code:
#include <cstring.h>
#include <iostream.h>
#include <conio.h>
#include <fstream.h>
#include <stdio.h>
int main()
{
string strLine;
fstream inFile;
inFile.open( "marks.txt",ios::in );
int size;
size = 0;
while( getline( inFile, strLine ) )
{
//getline( inFile, strLine );
cout << strLine << endl;
int space = strLine.find_first_of( " " );
cout << "First space at position " << space << endl;
int res = atoi(&(strLine.c_str())[space]);
cout << "Converted int is " << res << endl;
getch();
}
inFile.close( );
char *p;
p = strtok(strLine, " ");
cout << p << endl;
getch();
}
Could i get some help with it.