The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
strupr() is one of the inbuilt string function in c programming which is used to converts the lowercase characters to UPPERCASED characters.
The following diagram clearly illustrate the working principle of strupr() inbuilt string function in C.
In the above diagram strupr() takes a single parameter which is of string type. strupr() will transform all lowercased characters to UPPERCASED characters.
strupr(str);
Let us work through strupr() function. In the following program we will transform all lowercased characters to UPPERCASED characters by using strupr() inbuilt string function.
#include <stdio.h> #include<string.h> int main() { char str[30] = "this is strupr"; printf("The string in uppercase : %s ", strupr(str)); return 0; }
THIS IS STRUPR
The above program prints the uppercase letters of a string str.
Let us transform all lowercased characters to UPPERCASED characters in a string without using inbuilt string function strupr().
#include <stdio.h> #include<string.h> int main() { char str[30] = "this is strupr", i; for(i=0; str[i]!='\0';i++) { if(str[i]!=32){ // filtering blank space printf("%c",str[i]-32); } else printf(" "); } return 0; }
THIS IS STRUPR
The above program looks verbose but yields same the result.
When a string containing '\0' in its middle i.e) This\0willbreak, then strlen() will break and return the count upto '\0' i.e) it returns 4.
#include <stdio.h> #include<string.h> int main() { char str1[] = "This\0willbreak"; printf("Length of str1 = %d ", strlen(str1)); return 0; }
Length of str1 = 4
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019