Thread: Defining Buffer size for write to file

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    3

    Defining Buffer size for write to file

    Hi,
    I am writing a code for an I/O Benchmark application in C and I need to change the block size of read and write of a file from and to a disk. I am not able to figure out a way to do that. Can some one help me out with this?
    Thanks in advance.

  2. #2
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    I don't think if you can do it explicitly...
    I don't care if someone doesn't like me, i was not put on earth to entertain everyone.

    No King, no Queen, I am the ACE of battle.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    3
    Is there any way to do it???

    Is there any way to do this? cos I am not able to find any

  4. #4
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    What C functions are you using to read/write?
    Edit: If you are using stdio.h functions, you could use setvbuf.
    Last edited by Bayint Naung; 03-21-2011 at 01:56 AM.

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    3
    Thanks for that...

    I am just wondering if the setvbuf function would change the size of the write or read block size?????

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Which OS/Compiler are you using?

    To get the most representative benchmarks, you need to use the lowest level API routines available from your OS.

    The C standard API on top of that varies in complexity from one OS to another.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  4. Error with a vector
    By Tropicalia in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2006, 07:45 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

Tags for this Thread