char str[]={"January","Februray","March","Apri","May","June","August","September","October","November"};这样写对吗
时间: 2024-06-02 17:04:38 浏览: 105
这样的写法基本上是正确的,但是存在一个拼写错误,"Februray"应该是"February"。此外,这个字符数组没有指定长度,如果在程序中对其进行修改,可能会导致溢出问题。因此,更好的写法是在定义时指定数组的长度,例如:
```
char str[][10]={"January","February","March","April","May","June","July","August","September","October","November","December"};
```
这样定义的话,每个字符串都有10个字符的空间,可以保证足够存储对应的月份名称。
阅读全文