P
Prasanth
I have file named as "test.txt". The contents of the file are as
follows :
item1,sal,1000
item2,sal,2000
I am trying to read the file. And spilt each line as per delimiter ","
and push it into an array. That is
array[0][0] = item1
array[0][1] = sal
array[0][2] = 1000
array[1][0] = item2
array[1][1] = sal
array[1][2] = 2000
Please help me out over here
The program which i have written is below:
#include <iostream.h>
#include <string.h>
#include <conio.h>
#include <fstream.h>
#include <process.h>
int main()
{
clrscr();
ifstream inf;
char line[80];
char a[10][10];
inf.open("c:\\test.txt");
{
int j=0;
int w=0;
int i;
while(!inf.eof())
{
cout << line;
for(i=0;i<80;i++,j++)
{
cout << line << endl;
a[w][j] = line;
if(line == ' ')
w++;
}
}
}
cout << a[1];
inf.close();
getch();
return 0;
}
Please help me out as soon as possible.
Thanks,
Prasanth
follows :
item1,sal,1000
item2,sal,2000
I am trying to read the file. And spilt each line as per delimiter ","
and push it into an array. That is
array[0][0] = item1
array[0][1] = sal
array[0][2] = 1000
array[1][0] = item2
array[1][1] = sal
array[1][2] = 2000
Please help me out over here
The program which i have written is below:
#include <iostream.h>
#include <string.h>
#include <conio.h>
#include <fstream.h>
#include <process.h>
int main()
{
clrscr();
ifstream inf;
char line[80];
char a[10][10];
inf.open("c:\\test.txt");
{
int j=0;
int w=0;
int i;
while(!inf.eof())
{
cout << line;
for(i=0;i<80;i++,j++)
{
cout << line << endl;
a[w][j] = line;
if(line == ' ')
w++;
}
}
}
cout << a[1];
inf.close();
getch();
return 0;
}
Please help me out as soon as possible.
Thanks,
Prasanth