Changing to ASCII......

Discussion in 'C Programming' started by swetha, Nov 19, 2007.

  1. swetha

    swetha Guest

    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;
    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.....
    swetha, Nov 19, 2007
    #1
    1. Advertising

  2. swetha

    santosh Guest

    In article
    <>,
    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.
    santosh, Nov 19, 2007
    #2
    1. Advertising

  3. On Nov 19, 11:10 am, swetha <> wrote:
    > 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;
    > 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.....


    Few design logics together with
    string functions should help you.

    Karthik Balaguru
    karthikbalaguru, Nov 19, 2007
    #3
  4. swetha

    Sheth Raxit Guest

    On Nov 19, 11:10 am, swetha <> wrote:
    > 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;
    > 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.....


    refer man page of fopen, fread, fwrite and fclose.
    Sheth Raxit, Nov 19, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TOXiC
    Replies:
    5
    Views:
    1,231
    TOXiC
    Jan 31, 2007
  2. James O'Brien
    Replies:
    3
    Views:
    238
    Ben Morrow
    Mar 5, 2004
  3. Alextophi
    Replies:
    8
    Views:
    490
    Alan J. Flavell
    Dec 30, 2005
  4. bruce
    Replies:
    38
    Views:
    258
    Mark Lawrence
    Nov 1, 2013
  5. MRAB
    Replies:
    0
    Views:
    87
Loading...

Share This Page