Solved

regarding file handling in C

Posted on 2006-07-17
7
197 Views
Last Modified: 2010-04-15
I have a conf file in my hand:
this is:

YYYY:

1. .......
2. ..........
3...................;

ZZZZ:
1. ..........
2. ..........
3. ................;

now I write an app which takes input YYYY/ZZZZ and search for that and returns the string upto ";" who I do that.

rgds,
0
Comment
Question by:arijit_rebaca
  • 3
  • 3
7 Comments
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 17120119
Post the code that you have done so far !
0
 
LVL 8

Expert Comment

by:manish_regmi
ID: 17120217
1) open the file
2) read it in string.
3) use strstr to locate the YYYYY string
4) copy the string from : to ; to another string and return;


regards
Manish regmi
0
 

Author Comment

by:arijit_rebaca
ID: 17120344
with the help of which api i read it in string ? i.e. 2 is it fgets() ?
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:arijit_rebaca
ID: 17120365
and also the 4 th... with the help of which API?
0
 
LVL 8

Accepted Solution

by:
manish_regmi earned 50 total points
ID: 17120369
There are many, the choice is yours,

fgets()
fread()
read()

etc

regards
Manish regmi
0
 

Author Comment

by:arijit_rebaca
ID: 17120386
and for the 4th one?
0
 
LVL 8

Expert Comment

by:manish_regmi
ID: 17120394
the returned pointer from strstr points to the beginning of substring you searched. Now skip the words you searched. copy character by character until you get ';'.

char *ptr;
char *tosearch = {"YYYY:"};

ptr = strstr(whole, tosearch);

ptr += strlen(tosearch);

copy ptr[i] to other variable until you get ;

regards
Manish regmi


0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to connect an iphone application to mysql database 10 202
Need example 5 113
How to programmatically differentiate between C and Java 10 195
Problem to show menu 5 88
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question