reading a file into a block

This is a discussion on reading a file into a block within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by cyberfish For non-Linux/UNIX people, the dd program, in this case, copies big_file (a 100MB file with random ...

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,549
    Quote Originally Posted by cyberfish View Post
    For non-Linux/UNIX people, the dd program, in this case, copies big_file (a 100MB file with random data) to "copy" in block sizes specified in bs. The speed increase is negligible beyond 16KB blocks. (no, I don't have a 400MB/s harddrive, it is probably caching/buffering in effect)
    It seemed to me that the trade-off is somewhere around 64K blocks. Caching is and reading access can be optimized and varies on OS factors, so it may increase beyond the actual reading capabilities of the HD, but you can still improve time, so I'd definitely argue they do count.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    well this is all on the order of several KBs, I think it would be safe to say that there is negligible difference between something like 1MB and 1GB.

  3. #18
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,549
    Perhaps. It's difficult to say, but I would agree that about 64K blocks is a good thing.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Registered User
    Join Date
    Jul 2007
    Posts
    32
    what I like is complete the exercise with the read(); it's not clear to me if I have to use memset to clean the memory or/and put the '\0' (anche in wich position).

    Thanks.

  5. #20
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,549
    I'm guessing that your '\0' ends up at the wrong place (too late), so you get some garbage.
    The easiest way is, of course, memset.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  4. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

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