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

Every time you visit for the FIRST TIME today... [Part 1]

Name: Anonymous 2013-10-20 22:56

Post a random function that you made. May be from any project you've done or make one impromptu.

Any QUALITY is allowed. No bullying!

Name: Anonymous 2013-12-26 18:22

Is there any reason this is bad practice?


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

void *error(char *f, char *fmt, ...) {
va_list args;
va_start(args, fmt);
fprintf(stderr, "error: ");
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
va_end(args);

if(f)
perror(f);

exit(1);
}

int main(int argc, char **argv) {
int c;
FILE *f;
(f = fopen(*++argv, "r")) || error("fopen", "Couldn't open %s", *argv);

while((c = fgetc(f)) != EOF)
putchar(c);

return(0);
}

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