我遇到转换问题。我不能使用字符串在这个节目,所以我不得不使用char
的 - 我得到的错误:不能将Const Char [21]转换为Char?
error C2664: 'printText' : cannot convert parameter 1 from 'const char [21]' to 'char'
1> There is no context in which this conversion is possible
我试图将其转换为一个常量指针:
void printText(const char* text[100] = "notextgiven"...
,但它不“ t似乎有所帮助,给了我更多的错误。
我的计划:
#include <iostream>
using namespace std;
void printText(char, char, int);
int main(){
printText("I hear and I forget.", "*", 15);
}
void printText(char text[100] = "notextgiven", char symbol = ' ', int repeat = 10){
int temp = 0;
while(temp < repeat){
cout << symbol;
temp++;
}
cout << text;
temp = 0;
while(temp < repeat){
cout << symbol << endl;
temp++
}
}
此外,'“*”''应该是''*''而不是... – 2012-08-25 22:21:43
你知道字符(字符)和字符串之间有什么区别吗? – jalf
@Derp不要更新代码来回答你的问题。保持原样。如果其他人出现这个问题,并且发现代码中没有错误,但是看到你正在寻求帮助解决一些不存在的问题?他们会感到困惑。下次,请不要更改您的问题或您的代码。您应该这样做的唯一原因是为了清晰起见。 – 0x499602D2