string converting upper/lower
I have a problem. I have to accept input and convert it to lower case if it is upper case, and vice versa. If i enter "HarrY" i should get "hARRy".
My code stops for some reason after a string has been entered. Can somebody please help me fix it up so that i can get it working. Here is what i have so far, as u can see i am a bit stumped with the reverseCase function:
Code:
#include <stdio.h>
#include <string.h>
#define STRINGSIZE 100
void getString(char *string);
void reverseCase(char *string);
int numGraph(char *string);
int main()
{
char string[STRINGSIZE];
int count;
getString(string);
printf("Entered string => %s", string);
count = numGraph(string);
printf("Number of graphic characters in string = %d\n", count);
reverseCase(string);
printf("Reverse case => %s");
return 0;
}
void reverseCase(char *string)
{
/*converts uppercase into lowercase and lowercase into uppercase */
}
int numGraph(char *string)
{
/* Calculate the number of printable graphic characters in the
string.
*/
int count;
while (string != '\0')
{
if (isgraph((int) *string)) count++;
}
return count;
}
void getString(char *string)
{
printf("Please enter a string to process\n");
fgets(string, STRINGSIZE, stdin);
}