...
Code Block |
---|
int main(int argc, char *argv[]) {
char *str = NULL;
if (argc == 2) {
str = malloc(strlen(argv[1])+1);
if (str == NULL) {
/* Handle Allocation Error */
}
strcpy(str,argv[1]);
}
else {
str = "usage: $>a.exe [string]";
printf("%s\n", str);
}
/* ... */
free(str);
return 0;
}
|
...
Code Block |
---|
int main(int argc, char *argv[]) {
char *str = NULL;
if (argc == 2) {
str = malloc(strlen(argv[1])+1);
if (str == NULL) {
/* Handle Allocation Error */
}
strcpy(str, argv[1]);
}
else {
printf("usage: $>a.exe [string]\n");
return 1;
}
/* ... */
free(str);
return 0;
}
|
...