Please write out four methods to access all the elements in the array test.

CSDN Q & A 2022-05-14 13:20:36 阅读数:457

writemethodsaccesselementsarray

int test[]={20,30,40,50};

int *p = test;

Please write out four access arrays test Method for all elements in .




Take the answer :
 The first one is :int i;for(i = 0; i < 4; i++){ printf("%d ", test[i]);} The second kind :int i;for(i = 0; i < 4; i++){ printf("%d ", *(test+i));} The third kind of :int i;for(i = 0; i < 4; i++){ printf("%d ", p[i]);} A fourth :int i;for(i = 0; i < 4; i++){ printf("%d ", *(p++));}

版权声明:本文为[CSDN Q & A]所创,转载请带上原文链接,感谢。 https://qdmana.com/2022/134/202205071940314854.html