homepage Welcome to WebmasterWorld Guest from 184.73.40.21
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
Forum Library, Charter, Moderators: phranque

Website Technology Issues Forum

    
C programming
peiliu

10+ Year Member



 
Msg#: 380 posted 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);
}


 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved