to get strings and numbers from the line of text, you can use stringstream:
1 2 3 4 5 6 7 8 9 10 11
string line="abc def 123";
stringstream ss(line);
string txt1,txt2;
int number;
ss >>txt1>>txt2>>number; // extract data from line
cout <<"text: "<<txt1<<" "<<txt2<<endl;
cout <<"number: "<<number<<endl;
#station name
Station Name : A1
#octan of fuel 6.54 full service price 6.40 self service
Octan95,6.54,6.40
Octan98,8.30,8.15
#carNum,Octan,numOfLiters,Kind of service
22-334-55,95,31.3,FullService
22-334-55,95,31.3,SelfService
11-444-77,95,12,FullService
11-444-77,95,44.1,FullService
11-444-77,95,11.22,SelfService
and i need to take only the ----A1-----
and after that only the ----octan95----
all i have to do is take specific words from the txt file
#station name
Station Name : A1
#octan of fuel 6.54 full service price 6.40 self service
Octan95,6.54,6.40
Octan98,8.30,8.15
#carNum,Octan,numOfLiters,Kind of service
22-334-55,95,31.3,FullService
22-334-55,95,31.3,SelfService
11-444-77,95,12,FullService
11-444-77,95,44.1,FullService
11-444-77,95,11.22,SelfService
[code]Your code goes here[/code] (I wonder if this is going to work)
Basic structure of a c++ program:
1 2 3 4 5 6 7
#include <whatever_library_you_use>
int main() //or with arguments int main(int n, char **args)
{
//Main logic here
return 0;
}
To use string, stringstream, cout you need to include the headers: #include<string> , #include<sstream> , #include<iostream> respectively.
Don't forget that they are in the std namespace.