fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int string_length(int (*s)[10],int L,int W) {
  4. int len=0;int i,j;
  5. for(i=0;i<L;i++){
  6. for(j=0;j<W;j++)
  7. {len++;printf("%d ",*(*(s+i)+j));}
  8. printf("\n");
  9. }
  10. return len;
  11. }
  12. int main(int argc,char** argv) {
  13. int str[20][10]={{2,1,3,1,1,1,1,1,1,1},{2,1,3,1,1,1,1,1,1,1},{2,1,3,1,1,1,1,1,1,1}, {2,1,3,1,1,1,1,1,1,1},{2,1,3,1,1,1,1,1,1,1}};
  14. printf("the sizeof this 2d array will be %u \n",sizeof(str));
  15. printf("the length of the strings will be %u \n",sizeof(str)/sizeof(str[0]));
  16. printf("the width of the each string %u \n",sizeof(str[0])/sizeof(str[0][0]));
  17. printf("the result is %d \n",string_length (str,sizeof(str)/sizeof(str[0]),sizeof(str[0])/sizeof(str[0][0])));
  18. int i=0;
  19. while(i<10)
  20. printf("hello %d\n",i),i++;
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
the sizeof this 2d array will be 800 
the length of the strings will be 20 
the width of the each string 10 
2 1 3 1 1 1 1 1 1 1 
2 1 3 1 1 1 1 1 1 1 
2 1 3 1 1 1 1 1 1 1 
2 1 3 1 1 1 1 1 1 1 
2 1 3 1 1 1 1 1 1 1 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
the result is 200 
hello 0
hello 1
hello 2
hello 3
hello 4
hello 5
hello 6
hello 7
hello 8
hello 9