473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Read a .csv file in Windows 2000 using c

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....
Feb 5 '07 #1
3 1503
#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.....
Feb 5 '07 #2
#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...
Feb 5 '07 #3
Thanks a lot Rajesh...
really appreciate it...
Rajesh fread is reading only 1 byte.....
PLease give some info on std::fstream
Feb 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: santhosh_176 | last post by:
:I Created a Pocket PC application for iPAQ 5450. Every thing went fine even installer creation. I could run the setup and install it into the actual device and worked fine. The application enables...
11
by: typingcat | last post by:
Is it possible to read another web page in PHP? If is ASP.NET, the code would be ------------ WebRequest req=WebRequest.Create("http://www.microsoft.com"); WebResponse res=req.GetResponse();...
3
by: Analyst | last post by:
Is it possible to install DB2 CAE v5.2 using a response file ? From one of IBMs tech article, I found that the IBM DB2 Universal DB can be installed using a response file. My objective it to...
6
by: Dan V. | last post by:
Is there a way to query a remote xml file periodically by not using web services? For Windows and Unix platforms. Is there a cheap software product that I can install on each client and my Windows...
2
by: Michal Valent | last post by:
Hello, if I try to read a file on the mapped network drive, this error apears: Logon failure: unknown user name or bad password. How to set up permissions for IUSR_MACHINENAME on the mapped...
2
by: Jared Hagel | last post by:
I've searched the web for a solution to this problem. Surprisingly, no problem/solution has been posted yet. We can read application configuration information fine when our asp.net application...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
2
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified...
5
by: jannordgreen | last post by:
I use windows 2000 and Visual Studio 2003. I have a vbnet web application on our intranet that needs to read a text file that sits on a different server. The general user does not have access to...
4
by: Seok Bee | last post by:
Dear Experts, I have created a script to extract the Event Logs from the system into an excel sheet. The logs are separated into 2 worksheets (Application Log and System Log). After this excel...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.