variable length records for strings

This is a discussion on variable length records for strings within the C Programming forums, part of the General Programming Boards category; hai friends i have difficulti in making a structure field....of strings with vairable length .....i think we should do with ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    4

    Question variable length records for strings

    hai friends

    i have difficulti in making a structure field....of strings with vairable length .....i think we should do with linked list right if not is there any other source to write variable length records

    pls help me

    regards
    teja

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Variable length how?

    Like:

    record1:
    joe
    25
    14 elm street
    somecity, somestate 00010
    cat
    red
    ford

    record2:
    bob

    record3:
    tom
    1515 37th street east
    somecity, somestate 12345-1222
    dog


    ...OR...

    Variable lengths of strings, but the record format is always the same:

    record1:
    10
    Time flys when you're having fun
    2.455

    record2:
    245
    Time stands still.
    354.1

    record 3:
    20
    Once upon a time, in a land far far away, there lived a C programmer. It was his job to make wonderful programs for the king. All was well and happy in the land of the programmer, until one day, he forgot to initialize a pointer before using it. Much chaos ensued. The lone programmer set off on a quest to find the legendary 'debugger'. Many long nights later, the programmer mastered the 'debugger', and tracked down the nasty evil bug. All was happy in the land again. He lived happily ever after.
    2345.0



    In either case, there are a few ways to pull this off. If the first scenario, you could use a linked list which contains the "type", the "size", and the "data". Then make a keyword similar to what I've done with "recordX", and write it all that way. That's just one way to do it...

    In the second, just write your structures all to one file, and your strings to another. (Or, write your structure to the file, next, write an integer which contains the size of the string, then write the string itself. Repeat.

    There are many ways to do this. Clarify what you need.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. read a text file with lines of variable length
    By raymond in forum C Programming
    Replies: 7
    Last Post: 06-24-2006, 06:41 PM
  2. Question about printing a variable???
    By Hoser83 in forum C++ Programming
    Replies: 2
    Last Post: 03-31-2006, 12:57 PM
  3. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 01:45 PM
  4. Obtaining length from char * variable
    By bob2509 in forum C++ Programming
    Replies: 9
    Last Post: 04-20-2002, 04:36 PM
  5. length of string etc.
    By Peachy in forum C Programming
    Replies: 5
    Last Post: 09-27-2001, 12:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21