일부 문자가 포함 된 C++ 문자열이 있습니다. 특정 문자를 만나면 char 색을 어떻게 바꿀 수 있습니까? 어쩌면 이것은 당신이 싶은 무엇C++ SetConsoleTextAttribute 문자열의 char 변경.
#include <iostream>
#include "windows.h"
using namespace std;
int main()
{
HANDLE h;
h = GetStdHandle(STD_OUTPUT_HANDLE);
string str = "my name is meow.";
for(int i=0; i<str.length(); i++)
{
if(str[i] == 'm')
{
//change the char 'm' to red color..
}
cout<<str[i];
}
return 0;
}
나는 왜 대답이 질문의 제목에 이미 포함되어 있는지 궁금해하는 유일한 사람입니까? –