Solved

regarding file handling in C

Posted on 2006-07-17
7
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

630 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