#include %26lt;stdio.h%26gt;
char* strRev(char* line);
//your code here
char* str2Lower(char* line);
main(void){
//your code here
while(opt != 4){
printf("\n--------------------------...
printf("\nCST220 --- Assignment 2\n");
printf("Joe Smith XXX-YY-ZZZZ\n\n");
printf("Please choose the type operation\n");
printf("1. Reverse an string\n");
printf("2. Change an string to upper case\n");
printf("3. Change an string to lower case\n");
printf("4. End application (Exit)\n");
printf("Option: ");
scanf("%d", %26amp;opt);
if(opt != 4 %26amp;%26amp; (opt %26gt;= 1 %26amp;%26amp; opt %26lt;= 3)){
printf("\n\nPlease enter the string: ");
//your code here
if(opt == 1){
printf("\nThe reversed string is : %s", strRev(str));
}
else if(opt == 2){
printf("\nThe string in uppercase: %s", str2Upper(str));
}
else if(opt == 3){
printf("\nThe string in lowercase: %s", str2Lower(str));
}
}
}
}
char* strRev(char* line){
//your code here
return str2;
}
char* str2Upper(char* line){
//your code here
return str2;
}
char* str2Lower(char* line){
//your code here
return str2;
}
I need help completing this C code. Basically it asks user for input String and reverses it and changes cases.
#include %26lt;ctype.h%26gt;
char* strRev(char* line) {
char *str2, first;
str2 = line+strlen(line)-1;
while (str2%26gt;line) {
first = line;
*line = str2;
*str2 = first;
line++;
str2--;
}
return str2;
}
char* str2Upper(char* line) {
while( *line ) {
*line = toupper(*line);
line++;
}
return line;
}
char* str2Lower(char* line) {
while( *line ) {
*line = tolower(*line);
line++;
}
return line;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment