Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Im in your hdd adding null bytz

Name: Anonymous 2007-02-04 9:50

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv) {
   
    FILE *fp;
    int i = 0;
    long bytes, filesize;
   
    if(argc != 3) {
        fprintf(stderr, "Usage: %s [file] [bytes to write]\n", argv[0]);
        exit (1);
    }
   
    fp = fopen(argv[1], "a");
   
    if(!fp) {
        fprintf(stderr, "Error: Cant write to %s\n", argv[1]);
        exit (2);
    }
   
    bytes = atoi(argv[2]);
   
    if((isdigit(bytes)) || (bytes <= 0)) {
        fprintf(stderr, "Error: %s is not a valid number of bytes\n", argv[2]);
        fclose(fp);
        exit (3);
    }
   
    fseek(fp, 1, SEEK_END);
    filesize = ftell(fp);
    rewind(fp);
   
    printf("size of %s: %ld\nBytes to add: %ld\n", argv[1], filesize, bytes);
   
    while(bytes--) {
        fputc(0, fp);
        i++;
    }
   
    fseek(fp, 1, SEEK_END);
    filesize = ftell(fp);
    fclose(fp);
   
    printf("size of %s: %ld\n", argv[1], filesize);
}

Name: Anonymous 2007-02-04 10:23

how is it shitty?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List