473,468 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Reading a file

1 New Member
Hi all,
Using C i am reading a text file As follows
Expand|Select|Wrap|Line Numbers
  1.  
  2.         fp=fopen(g_inpfile,"r");
  3.  
  4.         if(fp==NULL)
  5.         {
  6.                 fprintf(stderr,"Error.Unable to open input file %s\n",g_inpfile);
  7.                 exit(-1);
  8.         }
  9.  
  10.         while(fgets(curline,300,fp)!= NULL)
  11.         {
  12.                 if(strncmp(curline,"Total of Account Failed to Suspend :",36)==0)
  13.                 {
  14.                         ACC_FOUND=1;
  15.                 }
  16.                         if(ACC_FOUND==1)
  17.                         {
  18.                                 sprintf(begin,"%s",curline);
  19.                                 val_rec_ind=val_line_chk(begin);
  20.                                         {
  21.                                                 if(strncmp(curline,"RC Resumption",13)==0)
  22.                                                 {
  23.                                                         ACC_FOUND=0;
  24.                                                 }
  25.                                                 if(val_rec_ind==1)
  26.                                                 {
  27.                                                         newstr=server_id(curline);
  28.                                                         strcpy(serv_id,newstr);
  29.                                                         printf("the value of server_id is %s\n",serv_id);
  30.                                                         linecnt++;
  31.                                                         printf("the value of curline is %s\n",begin);
  32.                                                 }
  33.                                         }
  34.                         }
  35.         }
  36. fclose(fp);

i am able to extract all the information .But my only concern is I dont want to passs the first line to the function server_id which is "Total of Account Failed to Suspend", Need help for this
Jun 11 '07 #1
2 974
gpraghuram
1,275 Recognized Expert Top Contributor
Hi,
I cant get your question fully.
If you dont want to pass the string means ,
r u asking that u dont want to hard code
or
do u want to pass it as an argument.

If you can explain this then i can take a look into it.

Raghuram
Jun 11 '07 #2
r035198x
13,262 MVP
Hi all,
Using C i am reading a text file As follows

fp=fopen(g_inpfile,"r");

if(fp==NULL)
{
fprintf(stderr,"Error.Unable to open input file %s\n",g_inpfile);
exit(-1);
}

while(fgets(curline,300,fp)!= NULL)
{
if(strncmp(curline,"Total of Account Failed to Suspend :",36)==0)
{
ACC_FOUND=1;
}
if(ACC_FOUND==1)
{
sprintf(begin,"%s",curline);
val_rec_ind=val_line_chk(begin);
{
if(strncmp(curline,"RC Resumption",13)==0)
{
ACC_FOUND=0;
}
if(val_rec_ind==1)
{
newstr=server_id(curline);
strcpy(serv_id,newstr);
printf("the value of server_id is %s\n",serv_id);
linecnt++;
printf("the value of curline is %s\n",begin);
}
}
}
}
fclose(fp);


i am able to extract all the information .But my only concern is I dont want to passs the first line to the function server_id which is "Total of Account Failed to Suspend", Need help for this
Chaged thread title. Please choose a more specific title next time.
Jun 11 '07 #3

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

Similar topics

4
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # to open a file and write to file # do f=open('xfile.txt','w') # this creates a file "object" and name it f. # the second argument of open can be
1
by: fabrice | last post by:
Hello, I've got trouble reading a text file (event viewer dump) by using the getline() function... After 200 - 300 lines that are read correctly, it suddenly stops reading the rest of the...
19
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much...
4
by: Oliver Knoll | last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode (that is just writing, right?). How would one reopen it for reading? I got the following (which works): FILE *tmpFile =...
6
by: Rajorshi Biswas | last post by:
Hi folks, Suppose I have a large (1 GB) text file which I want to read in reverse. The number of characters I want to read at a time is insignificant. I'm confused as to how best to do it. Upon...
1
by: Need Helps | last post by:
Hello. I'm writing an application that writes to a file a month, day, year, number of comments, then some strings for the comments. So the format for each record would look like:...
7
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should...
5
blazedaces
by: blazedaces | last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
2
by: Derik | last post by:
I've got a XML file I read using a file_get_contents and turn into a simpleXML node every time index.php loads. I suspect this is causing a noticeable lag in my page-execution time. (Or the...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.