int main(int argc, char** argv) { int x1 = add_together(10, 18); if (x1 > 10 && x1 < 100) { puts("x is greater than ten and less than one hundred!"); } else { puts("x is either less than eleven or greater than ninety-nine!"); } int i = 5; while (i > 0) { puts("Hello, World!"); i = i-1; } for (int i = 0; i < 5; i++) { puts("Hello, for-loop!"); } lewp(10); return 0; }
int main(int argc, char **argv) { char *name = NULL; int i = 1, ret = 0, daemon = 0; if(argc > 1 && !strcmp(argv[1], "-d")){ i++; daemon = 1; } for(; i < argc; i++) if(!name) name = argv[i]; else if(!host) host = argv[i]; else if(!port) port = argv[i]; else{ fprintf(stderr, "Unknown option: ``%s''\n", argv[i]); goto usage; } if(!host || !name) goto usage; if(!port) port = DEFAULT_PORT; if(setjmp(allocerr)){ perror("malloc()"); return 1; } if((ret = init_files())) return ret; if(daemon && daemonise()){ term_files(); return 1; } comm_init(&commt); if(comm_connect(&commt, host, port, name)){ outputf(file_err, "%s: couldn't connect: %s\n", *argv, comm_lasterr(&commt)); term_files(); return 1; } ret = lewp(); comm_close(&commt); term_files(); return ret; usage: printf("Usage: %s [-d] name host [port]\n" " -d: daemonise\n" , *argv); return 1; }