원본 자체의 C++ 프로그램 인쇄
따옴표, 줄 바꿈 처리: 이 두 문자는 일반적으로 문자열에서 뜻을 바꾸기 때문에 바꿀 때 직접 쓸 수 없고 ASCII 값으로 표시해야 한다.
#include <iostream>
using namespace std;
string replace_all(string src, char tc, string const & w)
{
string s(src);
string t(1, tc);
unsigned int pos = s.find(t), t_size = t.size(), r_size = w.size();
while(pos != std::string::npos){
s.replace(pos, t_size, w);
pos = s.find(t, pos + r_size );
}
return s;
}
int main()
{
char const *s = "#include <iostream>
using namespace std;
string replace_all(string src, char tc, string const & w)
{
string s(src);
string t(1, tc);
unsigned int pos = s.find(t), t_size = t.size(), r_size = w.size();
while(pos != std::string::npos){
s.replace(pos, t_size, w);
pos = s.find(t, pos + r_size );
}
return s;
}
int main()
{
char const *s = |@|;
char const q[] = {34,0};
char const n[] = {92,110,0};
cout << replace_all(replace_all(s,124,q), 64, replace_all(s, 10, n));
}
";
char const q[] = {34,0};
char const n[] = {92,110,0};
cout << replace_all(replace_all(s,124,q), 64, replace_all(s, 10, n));
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Visual Studio에서 파일 폴더 구분 (포함 경로 설정)Visual Studio에서 c, cpp, h, hpp 파일을 폴더로 나누고 싶었습니까? 어쩌면 대부분의 사람들이 있다고 생각합니다. 처음에 파일이 만들어지는 장소는 프로젝트 파일 등과 같은 장소에 있기 때문에 파일...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.