read content from file

for example:(hassan javaid \t google chrome)
i want to use getline function to ignore space between hassan and javaid
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
  #include<iostream>
#include<string>
#include<fstream>
using namespace std;


struct mail
{char rec[30];
char  sender[30];
char   subject[30];
char  content[30 ];
char time[30];
};
void mainmenu();

void PrintContact1(mail file1[],int last_index1,ofstream & out);
int readContact1(ifstream& in, mail file1[]);




int main()
{  mail file1[1000];
     int last_index1;
	 ofstream out;
	 out.open("detail.txt",ios:: app);
     ifstream in;
	 in.open("detail.txt");
	
	last_index1=readContact1(in,file1);
	 PrintContact1(file1,last_index1,out);
	 

	 

	return 0;
}



void PrintContact1(mail file1[],int last_index1,ofstream & out)
{   
	if(last_index1==0)
	{cout<<"The file is Empty\n";}
	for(int x=0;x<last_index1;x++)
	{
		
	
		out<<file1[x].rec<<'\t';
		out<<file1[x].sender<<'\t';
		out<<file1[x].subject<<'\t';
		out<<file1[x].content<<'\t';
		out<<file1[x].time<<'\t';
		out<<endl;
		}
	
}
int readContact1(ifstream& in, mail file1[])
{ 
	int c=0;
	int count=0;

	for(count=0;!in.eof();count++)
	{   
		
		\\ i want to ignore one space but getline '\t' not work\\

	     	
		in.getline(file1[count].rec,30,'\t');
		in.getline(file1[count].sender,30,'\t');
		in.getline(file1[count].subject,30,'\t');
		in.getline(file1[count].content,30,'\t');
		in.getline(file1[count].time,30,'\t');
		
		
	}
	c=count;
	return c;
}


Last edited on
Topic archived. No new replies allowed.