Skip to content

Instantly share code, notes, and snippets.

@abouolia
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abouolia/a50603b3d94dd4060e1a to your computer and use it in GitHub Desktop.
Save abouolia/a50603b3d94dd4060e1a to your computer and use it in GitHub Desktop.
Upper/Lower Case in C
#include<stdio.h>
#include<string.h>
#include<ctype.h>
char *uppercase( char str[256] );
char *lowercase( char str[256] );
main(){
char str[256] = "";
printf("Please Enter Your Name Fully\t");
scanf("%s", str);
printf("Upper Case: %s \t", uppercase( str ) );
printf("Lower Case: %s", lowercase( str ) );
}
//to convert any string to upper case
char *uppercase( char str[256] ){
int i;
for( i = 0; i < strlen(str); i++ ){
str[i] = toupper(str[i]);
}
return str;
}
//to conver any string to lowercase
char *lowercase( char str[256] ){
int i;
for( i = 0; i < strlen(str); i++ ){
str[i] = tolower(str[i]);
}
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment