Results 1 to 5 of 5

Thread: write the data to text file

  1. #1
    Join Date
    Jan 2013
    Posts
    44
    Thanks
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default write the data to text file

    hi everyone
    i want to write a data to a txt file with format as:
    1 data1
    2 data2
    ....
    n ..datan

    how i can write the data only to n=1000, if greater than 1000 ,it will begin write overwritten to 1 ,2 ...

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: write the data to text file

    Check the file size before you write. If it is greater than 1000, seek position to the begin of the file.

    You may also need to open file in append mode. Do confirm.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: write the data to text file

    Quote Originally Posted by vanduongbk View Post
    hi everyone
    i want to write a data to a txt file with format as:
    1 data1
    2 data2
    ....
    n ..datan
    Are those separate lines?
    Is each line the same length?

    Cheers,
    _

  4. #4
    Join Date
    Jan 2013
    Posts
    44
    Thanks
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: write the data to text file

    Quote Originally Posted by anda_skoa View Post
    Are those separate lines?
    Is each line the same length?

    Cheers,
    _
    hi,
    yes,it's separate line but its length is not similar as
    1 10
    2 100
    3 13.76
    ....

    hi aamer4yu

    If it is greater than 1000, seek position to the begin of the file.
    how can I do this ,can you explain it by a simple example

  5. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: write the data to text file

    After reaching the 1000 lines, you must create a file from scratch. This is impossible to put 10 characters in place of 5 characters.

Similar Threads

  1. Replies: 3
    Last Post: 8th June 2011, 06:36
  2. Write on a text file from QString
    By Malek in forum Newbie
    Replies: 3
    Last Post: 27th December 2010, 19:27
  3. Read/write data from file
    By Insomnium in forum Qt Programming
    Replies: 5
    Last Post: 10th December 2010, 07:35
  4. How to write data into a file
    By grsandeep85 in forum Qt Programming
    Replies: 9
    Last Post: 21st July 2009, 08:51
  5. FSWriteFork in MAC OS to write data to a file.
    By vishal.chauhan in forum General Programming
    Replies: 5
    Last Post: 2nd July 2007, 06:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.