#include <stdbool.h>
#include <string.h>
#include <ctype.h>
void noMoreNewline(char* theString){
char * isANewline;
isANewline = strrchr(theString, '\n');
// 개형문자
if(isANewline){
*isANewline = '\0';
}
}
void makeLowercase(char* theString){
int i = 0;
while(theString[i]){
// 소문자 변경
theString[i] = tolower(theString[i]);
// 대문자 변경
// theString[i] = toupper(theString[i]);
i++;
}
}
int main(void){
char doYouWantToQuit[10];
printf("Enter quit to quit: ");
fgets(doYouWantToQuit, 10, stdin);
noMoreNewline(doYouWantToQuit);
makeLowercase(doYouWantToQuit);
printf(doYouWantToQuit);
while(strcmp(doYouWantToQuit, "quit")){
printf("Enter quit to quit: ");
fgets(doYouWantToQuit, 10, stdin);
noMoreNewline(doYouWantToQuit);
makeLowercase(doYouWantToQuit);
}
printf("Thank you for typing quit %s\n\n", doYouWantToQuit);
}
댓글 없음:
댓글 쓰기