내 코드에서 "문자열 리터럴에서 char * 로의 변환이 중단되었습니다"오류가 계속 발생합니다. 코드의 목적은 pointer-to-pointer를 사용하여 string1과 string2에 단어를 할당 한 다음 인쇄하는 것입니다. 이 문제를 어떻게 해결할 수 있습니까? 당신이 법적으로 수정할 수 없음을 의미 const를char
의문자열 리터럴에서 char * 로의 변환이 더 이상 사용되지 않습니다.
#include <iostream>
using namespace std;
struct WORDBLOCK
{
char* string1;
char* string2;
};
void f3()
{
WORDBLOCK word;
word.string1 = "Test1";
word.string2 = "Test2";
char *test1 = word.string1;
char *test2 = word.string2;
char** teststrings;
teststrings = &test1;
*teststrings = test2;
cout << "The first string is: "
<< teststrings
<< " and your second string is: "
<< *teststrings
<< endl;
}
나는 당신의 코드를 조금 수정했습니다. 스크롤하지 않고 상단에 몇 줄을 추가하여 출력 문을 읽을 수 있도록 출력 문을 작성합니다. –
향후 검색을 위해 중복으로 표시 [지원되지 않는 문자열 리터럴에서 'char \ *'로의 변환] (http://stackoverflow.com/questions/9650058/deprecated-conversion-from-string-literal-to-char) –