0
Follow
0
View

Which of the c definitions of strings is correct?

cuixingwei05 注册会员
2023-02-28 11:32

B is the syntax for initializing an array. s is a pointer, not an array.

dhn8112 注册会员
2023-02-28 11:32

The

where you drew the line
xiong_sir 注册会员
2023-02-28 11:32
    < li > B should be defined as below: < / li >
const char *s = {"ABCD"};
  • A and C are definitely wrong; A int array, cannot assign a string; C two-dimensional array, initializes one-dimensional array data
  • D initializes two-dimensional array of type double, whose elements are all 0