如题所示,为什么字符串加了const
就会报错,去掉const
就能过?
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
const char letter[] = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
cout<<strlen(letter)<<endl;
return 0;
}
ringa_lee2017-04-17 15:09:58
Post the error message and take a look. It is normal to execute the following command under Mac and Centos after compilation
g++ test.cpp -o test
./test
迷茫2017-04-17 15:09:58
Thank you everyone, I made a mistake in the main function. I created two new main functions in a project, which caused this error. Thank you very much