Solved

regarding file handling in C

Posted on 2006-07-17
7
199 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

Independent Software Vendors: 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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
Suggested Courses

752 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