By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,405 Members | 1,040 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,405 IT Pros & Developers. It's quick & easy.

Reading a file

P: 1
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
Share this Question
Share on Google+
2 Replies


gpraghuram
Expert 100+
P: 1,275
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

10K+
P: 13,264
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

Post your reply

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