// this example illustrates the way to convert a string from lower case to upper case #include // for printf, scanf #include // for malloc, free #include // for is_lower int string_length(char * my_string) { int counter = 0; while(1) { if (my_string[counter] != 0) { counter++; } else { break; } } return counter; } char * convert_to_upper_case(char * text) { int length = string_length(text); int i; char * temp = (char *) malloc(sizeof(char) * (length+1)); for (i=0; i< length; i++) { if(islower(text[i])) { temp[i] = text[i] - 32; } else { temp[i] = text[i]; } } temp[length] ='\0'; return temp; } int main() { char * text = (char *) malloc(sizeof(char) * 1000); char * text_capital; printf("please enter a string (the length should be less than or equal to 1000):\n"); scanf("%s", text); text_capital = convert_to_upper_case(text); printf("the upper-case version of %s is %s\n", text, text_capital); free(text); free(text_capital); }