Files

In labsht.txt I have save 1d222bb433gf445dfd448dfdfdf4 which I input using this program
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
#include<iostream>
#include<fstream>
using namespace std ;
int main()
{
int itm;
char item[20];
int n;

ofstream makelist("labsht.txt");

  for (int a=0;a<5;a++)  
   {
     cout<<"Enter itemcode,item and price"<<endl;
     cin>>n>>item>>itm ;

  makelist<<n<<item<<itm ;
 
  }

makelist.close();
return 0;
}

this program is to print saved data.
but it gives this output
"1 d222bb433gf445dfd448dfdfdf4 0"
i want to get line by line.
can anyone help me to get the required output..?
thanks


#include<iostream>
#include<fstream>
using namespace std;
int main()
{
int s;
char b[2];
int c;


ifstream  show("labsht.txt");

while(!show.eof())
{
     show>>s>>b>>c;
   cout<<" "<<s<<" "<<b<<" "<<c<<"  "<<endl;
}

return 0;
}
Last edited on
you should really move this to the beginners section. i see nothing that warrants it being in the lounge
I don't want to try and read that... Sorry.
Also this is the lounge so it's general stuff not C problems.
Topic archived. No new replies allowed.