Read number from .txt file

**I have a text file contain a variety of text and numbers, **
i want to read a number from this .txt file
**For example: if the line 10 appear as follows: **

Name Baja 52525

I am write a simple code for that like this

how can i modify it to read this number?

{
ifstream inputfile;
ofstream outputfile;

inputfile.open("file.txt");

double N;
String line;
int linenumber=0;

while (!inputfile.eof()){

       if (linenumber==10){
        getline(inputfile, line, N);
        inputfile >>N;}

cout << "N="<<N<<endl;

inputfile.close();
}

hi,

root is not really involved in this program right?

cheers,

P

its already root code

it is perhaps a root macro but yours is really a basic c++ question since no root type appears in your code… btw, it is not clear what you are asking…

d

thank you ,

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.