Thread: How to Create sparse file with alternate data and hole.

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    1

    How to Create sparse file with alternate data and hole.

    Hi All,

    I have to write a program in c where I have to create a file with known pattern data and hole in it, and it should be such that a 4k data and then it will skip 12K and then again it will write the same 4k data .

    It should be such that

    data hole data hole data
    (4k) (12K) (4k) (12K) (4k)

    Please help me .....

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Someone actually wants you to write a program that wastes disk space?

    Ok... look up fseek(), fread() and fwrite() in your library documentation. That should give you some beginning ideas to build on.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Sparse Files
    If you write your 4K, then seek() forward 12K you may (or may not) end up with a sparse file.

    Sparse files are a feature of your file system, perhaps even your OS, and maybe even your compiler run-time library.
    You need to be more specific than "do this in C".
    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. Writing to NTFS alternate data streams on windows
    By e3vil in forum Windows Programming
    Replies: 1
    Last Post: 09-20-2011, 06:24 AM
  2. Replies: 5
    Last Post: 09-17-2011, 08:53 PM
  3. Create Sparse Matrix
    By kavka3 in forum C Programming
    Replies: 12
    Last Post: 02-08-2009, 03:23 PM
  4. alternate to string.data()
    By Eber Kain in forum C++ Programming
    Replies: 1
    Last Post: 06-07-2004, 12:59 PM
  5. read from alternate file on PC
    By brooklyn1126 in forum C++ Programming
    Replies: 1
    Last Post: 05-15-2004, 10:30 PM