error: array must be initialized with a brace-enclosed initializer char b[100]=cheng;
时间: 2024-03-07 16:47:52 浏览: 21
The error message suggests that you are trying to initialize a character array named "b" with the variable "cheng". However, in C++, a character array must be initialized with a brace-enclosed initializer, which means that the elements of the array should be enclosed in curly braces.
To fix the error, you could modify the initialization of "b" as follows:
```
char b[100] = {'c', 'h', 'e', 'n', 'g'};
```
This initializes the array "b" with the characters 'c', 'h', 'e', 'n', 'g' and pads the remaining elements with null characters. Alternatively, if you want to initialize "b" with a string, you could use double quotes to create a string literal:
```
char b[100] = "cheng";
```
This initializes the array "b" with the string "cheng" and pads the remaining elements with null characters.