Thread: how to create a file of specific size?

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    2

    how to create a file of specific size?

    I want to know the syntax to create a file of specific size...

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    fopen(), fwrite(), fclose() in that order.


    BTW this isn't really a place to request code.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Mandark View Post
    I want to know the syntax to create a file of specific size...
    You need to fseek() forward the number of bytes you want, then fwrite() a byte at that location.

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    2

    sorry

    this is my first post and I did'nt know the forum rules.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > this is my first post and I did'nt know the forum rules.
    So you missed all the posts at the top of each forum with titles like
    Forum Guidelines. Read before posting
    Click it NOW!
    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. File Writing Problem
    By polskash in forum C Programming
    Replies: 3
    Last Post: 02-13-2009, 10:47 AM
  2. Create File of X size
    By jcas1411 in forum C++ Programming
    Replies: 20
    Last Post: 02-07-2009, 12:42 PM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  5. File Size and File Size on Disk
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 12-15-2001, 08:03 PM