1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to read the data line by line from a File?

Discussion in 'C' started by Shilpa1, Dec 10, 2007.

  1. Shilpa1

    Shilpa1 New Member

    Joined:
    Nov 8, 2007
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    In my application,in Dialog1 writing the data line by line,upto this working perfectly,where as in Dialog2 while reading the data line by line always reading the first line.
    How to read the data line by line?Though simple one,Iam in confusion.Pls help me.

    In Dialog1, for File.txt ,writing the names as

    Name1
    Name2
    Name3

    and on the other side I want to read the names one by one,but In Dialog2 always reading the Name1,not going to the second line.

    In Dialog1

    In Dialog2

     
  2. Shilpa1

    Shilpa1 New Member

    Joined:
    Nov 8, 2007
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Hai,
    pls see the File.txt.In Dialog1 Iam encrypting the data and writing the encrypted data to File.In Dialog2, I want to read the encrypted data from File one by one.Is this correct way of writing encrypted data to a File or Is it better to encode the encrypted data?If anybody having the sample code for Encoding/Decoding pls post it.
     
    Last edited by a moderator: Dec 10, 2007
  3. Salem

    Salem New Member

    Joined:
    Nov 15, 2007
    Messages:
    133
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Please don't PM me for 1:1 support.
    1. Use [code][/code] tags when posting code.

    2. Why are you trying to read and write to the file at the same time?
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    Please try to post instead of giving it as an attachment. I have removed the attachment from the post.
     
  5. Shilpa1

    Shilpa1 New Member

    Joined:
    Nov 8, 2007
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    In File.txt Iam writing the following encrypted text.Now,I want to read the encrypted data line by line.How to do this?Pls help me.

     
  6. Salem

    Salem New Member

    Joined:
    Nov 15, 2007
    Messages:
    133
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Please don't PM me for 1:1 support.
    Encrypted by whom, using what algorithm and with what key?

    Good algorithms will destroy any sense of the idea of "lines" in the file and present you with a stream of what looks like random bytes.
     
  7. Shilpa1

    Shilpa1 New Member

    Joined:
    Nov 8, 2007
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Hai,
    My major problem is how to read the data line by line from a File?Pls gave me an idea.
     
  8. Salem

    Salem New Member

    Joined:
    Nov 15, 2007
    Messages:
    133
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Please don't PM me for 1:1 support.
    Well if it's encrypted you have two choices
    - fgetc, to read the file one byte at a time
    - fread, to read a whole block of bytes at a time.

    Having read some bytes, you then need to decrypt them in order to work out what the real data is, and where the lines are.
     

Share This Page