#include #include #include #include #include //** need assert for malloc check // convert "hello world" to "HELLO WORLD" int main(int argc, char ** argv){ char * s = "hello world"; int len = strlen(s); //** calculate strlen only once char * t = malloc(len+1); //** alloc string buffer assert(t); //** check for malloc error int i = 0; for ( ; i < len; ){ //** move strlen out of loop t[i] = toupper(s[i]); i++; //** } t[len] = '\0'; printf("t: %s \n", t); free(t); //** }