#include #include #include // for toupper() #include // for strcpy() typedef char* str; // How could/would you fix this method? str upperify(str s) { char result[strlen(s)+1]; // allocate space on stack strcpy(result, s); // copy string argument into result for (char *p=result; *p != '\0'; p++) { *p = toupper(*p); // upperfy, char by char } printf("%s\n", result); return result; // this is an error -- returning a pointer to stack memory that // is about to be freed } //------------------------------------------------------ // mainline //------------------------------------------------------ int main(int argc, char *argv[]) { int argIndex; // args before upperify'ing printf("1st phase (print args):\n"); for (argIndex=0; argIndex