Solved

regarding file handling in C

Posted on 2006-07-17
7
196 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now