Welcome to WebmasterWorld Guest from 54.227.83.19

Forum Moderators: phranque

Message Too Old, No Replies

C programming

     

peiliu

3:04 am on Apr 16, 2001 (gmt 0)



Comment on the following code.Could you note any potential problems either in program correctness, style, performance, or conformance to standards.

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

#pragma inline
int
update(int *value, int i) {
if (value > i) {
*value *= 64;
} else {
*value -= 5;
}
}

int
main(int argc, char *argv[]) {
char *foo;
int i, count;
FILE *fp;

sprintf(foo, "Current time is %s\n", time(NULL));
for (i=0; i < atoi(argv[1]); i++) {
if ((fp = fopen(argv[2], "a")) = NULL) {
printf("Couldn't open the file!\n");
exit(0);
}
update(check, i);
fprintf(fp, "Updated item %d is now %d\n", i, check);
close(fp);
}
if (argv[3] != NULL) {
sprintf(foo, "rm -f %s\n", argv[3]);
system(foo);
}
exit(0);
}

 

Featured Threads

Hot Threads This Week

Hot Threads This Month