Reading 2nd line and selecting particular letters(txt file)!!

My text file contains two lines:-

Tableno:1
s1,t2


Question:-
How to read only the 2nd line "s1,t2".
And in that i want only the letters (s and t) to be selected and it should be assigned its values (for eg:50 & 75).

My aim:-
To calculate the bill using the food codes(s1 and t2).


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//Restaurant Manager Table-2
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<windows.h>
using namespace std;

class table{
      public:
      
          void menu()
                 { 
                    ifstream menu;
                    menu.open("menu.txt");
                    string STRING;
                    string inFile_contents;
                    string previousLine="";
                    while(!menu.eof())
                     {
                       getline(menu,STRING); // Saves the line in STRING.
                       if (STRING != previousLine)
                       {
                         previousLine=STRING;
                         cout<<STRING<<endl; // Prints our STRING.
                       }
                     }
                    menu.close();
                 }
     
          void order()
               {int tno=2;
                char ordr[100];
                cout<<"\n\nPlease enter the food codes\n";
                cout<<"(Eg:like f2,d1,c3)\n";
                ofstream outfile;
                outfile.open("Order2.txt");
                cin.getline(ordr,100);
                outfile <<"TableNo: "<< tno <<endl << ordr <<endl;
                outfile.close();
                cout<<".";
                Sleep(800);
                cout<<".";
                Sleep(800);
                cout<<".";
                Sleep(1000);
                cout<<"Your order has been placed\n";
               }
           }c;
int main()
{   char x;
    c.menu(); 
    c.order();
    getch();
}
     


I use DevC++, the above codes are compiled and has no errors.
It looks like a good start; however, you need to read each line into its own variable.
Last edited on
May i pls have its code ??
What?
You read a line of data into your variable "ordr" on line 37. That is the first line in your input file.

Read the next line into your other variables.
K thank u kooth
it was helpful!! :)
I'm glad I was helpful! Please mark this as solved so that it might help others.
Topic archived. No new replies allowed.