程序:
------------------------------
char array[2]={"X"};
--其他程序--
array={"X"};
------------------------------
我的思想是先给array[2]赋初值,在经过--其他程序--处理后,array[2]的初值已发现变化,我想重新给它赋值{"X"},但是老是出错;
编译如下:
[root@localhost mb]# make
g++ -c -pipe -Wall -W -O2 -march=i386 -mcpu=i686 -g -DGLX_GLXEXT_LEGACY -fno-use-cxa-atexit -fno-exceptions -DQT_NO_DEBUG -I/usr/lib/qt-3.1/mkspecs/default -I. -I/usr/lib/qt-3.1/include -I.ui/ -I.moc/ -o .obj/main.o main.cpp
main.cpp: In function `int main(int, char**)':
main.cpp:9: invalid conversion from `const char*' to `char'
main.cpp:9: invalid conversion from `const char*' to `char'
main.cpp:9: invalid conversion from `const char*' to `char'
main.cpp:10: parse error before `]' token
main.cpp:7: warning: unused parameter `int argc'
main.cpp:7: warning: unused parameter `char**argv'
main.cpp: At global scope:
main.cpp:11: `argc' was not declared in this scope
main.cpp:11: `argv' was not declared in this scope
main.cpp:13: syntax error before `.' token
main.cpp:15: syntax error before `.' token
main.cpp:16: syntax error before `.' token
main.cpp:17: syntax error before `.' token
main.cpp:18: syntax error before `.' token
make: *** [.obj/main.o] Error 1
怎样给字符数组赋值啊?是不是字符在QT中的处理与其他地方的C/C++不同啊?
[ 此贴被XChinux在2005-09-05 22:02重新编辑 ]