Pam*_*nes 1 c arrays string pointers char
我该如何在c编程中调用它:
char *fileNames[3] = {"string1", "string2", "string3"};
Run Code Online (Sandbox Code Playgroud)
指针数组,指向字符串的数组,还是什么?
在其他地方寻找答案并不是很懒惰,而是我找不到它.
更新1:我已经调用了上面的(不管是什么)fileNames,因为我实际上是用它来存储文件名,但它可能是我的问题.
并且感谢你们进行了大量的辩论,但是有很多答案甚至很难确定哪一个对我来说是正确的.
该名称fileNames 是一个3 char*(char指针)数组,在您的声明中指向3个字符串文字.它被称为:'char'指针数组或'字符串数组',因为每个索引都指向一个字符串.你应该让它们保持不变:
const char *fileNames[3] = {"string1", "string2", "string3"};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
216 次 |
| 最近记录: |