Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Problem while splitting the line using a delimiter and pushing itinto an array
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Prasanth, post: 3682073"] 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[i] << endl; a[w][j] = line[i]; if(line[i] == ' ') w++; } } } cout << a[1]; inf.close(); getch(); return 0; } Please help me out as soon as possible. Thanks, Prasanth[/i][/i][/i] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Problem while splitting the line using a delimiter and pushing itinto an array
Top