Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
Read a .csv file in Windows 2000 using c
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
samuelpaulc
New Member
Join Date:
Feb 2007
Posts:
8
#1
Read a .csv file in Windows 2000 using c
Feb 5 '07, 09:51 AM
I need to extract data from .csv file Using C/C++ and need to sort them out....
Any help will be appreciated ...
Thanks in advance....
rajesh6695
New Member
Join Date:
Oct 2006
Posts:
96
#2
Feb 5 '07, 10:36 AM
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
FILE *fp;
char buf[1];
char a[20];
char b[15];
clrscr();
printf("Enter the path of the file :");
scanf("%s",&a);
fp=fopen(a,"a+" );
if(fp==NULL)
{
printf("Error : Not able to Open the file....\n");
getch();
exit(1);
}
printf("Content of a file ....\n");
fseek(fp,0, SEEK_SET);
while( !feof(fp) )
{
fread(buf, 1, 1, fp);
if(buf[0]==',')
{
printf("\t");
}
else
{
printf("%c", (buf[0]));
}
}
fclose(fp);
printf("\nPress any key to leave the process...\n");
getch();
return 0;
}
Look out the code and also there is an one error u find that error and fix it.....
Comment
Post
Cancel
samuelpaulc
New Member
Join Date:
Feb 2007
Posts:
8
#3
Feb 5 '07, 11:15 AM
Originally posted by
rajesh6695
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
FILE *fp;
char buf[1];
char a[20];
char b[15];
clrscr();
printf("Enter the path of the file :");
scanf("%s",&a);
fp=fopen(a,"a+" );
if(fp==NULL)
{
printf("Error : Not able to Open the file....\n");
getch();
exit(1);
}
printf("Content of a file ....\n");
fseek(fp,0, SEEK_SET);
while( !feof(fp) )
{
fread(buf, 1, 1, fp);
if(buf[0]==',')
{
printf("\t");
}
else
{
printf("%c", (buf[0]));
}
}
fclose(fp);
printf("\nPress any key to leave the process...\n");
getch();
return 0;
}
Look out the code and also there is an one error u find that error and fix it.....
Thanks a lot Rajesh...
really appreciate it...
Comment
Post
Cancel
samuelpaulc
New Member
Join Date:
Feb 2007
Posts:
8
#4
Feb 5 '07, 11:31 AM
Originally posted by
samuelpaulc
Thanks a lot Rajesh...
really appreciate it...
Rajesh fread is reading only 1 byte.....
PLease give some info on std::fstream
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment