In article
<9672e62e-9c04-44e5-8494->,
swetha <> wrote on Monday 19 Nov 2007 11:40 am:
> HI Every1,
> I have a file in binary format. Using a C program
> i
> have to read that file and need to make some changes . So i wanted to
> convert that into ACII format.Can any1 suggest me how to do that
> please.....
>
> ADDING TO IT .....
>
> The file i have is a data file(in binary mode) which consists of
> structures of type say --
>
> struct tab {
> char name;
Are you sure of the above declaration? 'name' can hold only a single
character of the source or execution character set. Perhaps 'name' is
an array, which would be more appropriate to hold a name of a person or
other object?
> int value;
> } ; I have to write a C program which searches this file with the
> name given by the user and returns or updates the value field of that
> particular user.....
First you have to decide whether you want to do the search as you read
from the stream (aka file) or whether you would prefer to read the
whole file, or a part of it, into memory (presumably into an array of
struct tab objects), before searching. If you will be performing many
searches, reading from memory is much better than reading a stream,
though the implementation's buffering may ameliorate matters.
In anycase the strcmp() and strncmp() functions should be useful. You
library should be having documentation for them. If not, look here:
<http://www.dinkumware.com/manuals/>
Post your attempt if you have further problems. We don't do your
homework for you.
|