게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
c++ 에서 string 대문자/소문자 교체하기
게시물ID : programmer_6290짧은주소 복사하기
작성자 : 오늘의웃음
추천 : 0
조회수 : 970회
댓글수 : 7개
등록시간 : 2014/11/01 16:26:14
옵션
  • 본인삭제금지
프로그램을 하나 연습중인데 잘 안돼네요.


#include <iostream>
#include <cctype>
#include <string>
#include <stdlib.h>
#include <time.h>
using namespace std;

string inverseString(string);

int main()
{
string str1;
getline(cin,str1);
inverseString(str1);
cout << str1;

return 0;
}


string inverseString(string str2)
{
int i;
for (i=0;i <= str2.length(); i++)
{
if (islower(str2[i]))
{
str2[i] = toupper (str2[i]);
}
else if (isupper(str2[i]))
{
str2[i] = tolower (str2[i]);
}
}
return str2;
}

이렇게 해서 str1에 인풋을 넣어줘도 대문자/소문자가 안바뀌고 그냥 그대로 나옵니다..도대체 왜이러는지 모르겠네요..OTL
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호