Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 访问字符串数组_C_String_Pointers - Fatal编程技术网

C 访问字符串数组

C 访问字符串数组,c,string,pointers,C,String,Pointers,对于以下字符串数组,如何访问arm中的a和candy中的c 基本上,我是C语言的新手,希望了解如何访问字符串数组中的特定字符 我使用以下代码定义数组: const char*str1[]={“arm”,“candy”}基本上你拥有的是一个数组数组,因此: char c = str1[0][1]; // value of c would be thr 'r' from arm 下面的代码为您提供了arm中的“a” str1[0][0]; str1[1][0]; 下面的代码为您提供了糖果

对于以下字符串数组,如何访问
arm
中的
a
candy
中的
c

基本上,我是C语言的新手,希望了解如何访问字符串数组中的特定字符
我使用以下代码定义数组:

const char*str1[]={“arm”,“candy”}

基本上你拥有的是一个数组数组,因此:

char c = str1[0][1]; // value of c would be thr 'r' from arm

下面的代码为您提供了arm中的“a”

str1[0][0]; 
str1[1][0]; 


下面的代码为您提供了糖果中的“c”

str1[0][0]; 
str1[1][0]; 

1) 读一本书。2) 使用编译器尝试一些代码。3) 如果你被卡住了,就这样问吧。按此顺序。类似于
str1[0][0]