is it possible to delete a portion of a file?

suppose i have a file of size 2000kb. can i delete about 1000kb and keep the remaining 1000kb ?if i can how to delete?

4 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    Open it up in note pad and Remove a chunk of it.

  • 1 decade ago

    Of course. Exactly how you accomplish this is very much relative to the programming language you are using. In general, you have two ways of opening a file: cooked mode or raw. This determines whether or not the file is read as a series of bytes or a series of characters. This might make a difference to your program. Probably to do what you describe, you'd have to open the file, read or seek to the 1k byte point, open a second file, and copy the remainig date onto the new file. Once you'd saved it, you'd delete the original file, and rename the new one to be the same as the original one.

  • 1 decade ago

    there is many option for this. (as mentioned earlier)

    tho u hav option to do it with ur own program. It is really easy to handle files in c.

    let the file u wanna concatanate has name "a.txt"

    follows the c program which will delete 1000 bytes from the file and leaving rest as it is

    #include<stdio.h>

    void main()

    {

    int i=0;

    char ch;

    FILE *ft,*f = foepn("a.txt","a+");

    ft = fopen("temp.txt","a+");

    while(!feof(f))

    {

    i++;

    if(i>1000)

    {

    fscanf(f,"%d",&ch);

    fprintf(ft,"%c",ch);

    }

    if(feof(f))

    break;

    }

    unlink(f);

    f = fopen("a.txt","a+");

    while(!feof(ft))

    {

    fscanf(ft,"%c",&ch);

    fprintff,"%c",ch);

    }

    unlink(ft);

    }

    this will do exactly what u are willing to do

    }

  • Anonymous
    1 decade ago

    Of couse you can. but firstable you need some programs to help you to seprate it. Please note you have to make sure it is legal according to the Copyright law.

Still have questions? Get your answers by asking now.