fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int string_length(int **s,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[5]={
  14. (int[]){2,1,3,1,1,1,1,1,1,1},
  15. (int[]){2,1,3,1,1,1,1,1,1,1},
  16. (int[]){2,1,3,1,1,1,1,1,1,1},
  17. (int[]){2,1,3,1,1,1,1,1,1,1},
  18. (int[]){2,1,3,1,1,1,1,1,1,1}
  19. };
  20. printf("the sizeof this 2d array will be %u \n",sizeof(str));
  21. printf("the length of the strings will be %u \n",sizeof(str)/sizeof(str[0]));
  22. printf("the width of the each string %u \n",sizeof(str[0])/sizeof(str[0][0]));
  23. printf("the result is %d \n",string_length(str,5,10));
  24. int i=0;
  25. while(i<10)
  26. printf("hello %d\n",i),i++;
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
the sizeof this 2d array will be 20 
the length of the strings will be 5 
the width of the each string 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 
2 1 3 1 1 1 1 1 1 1 
the result is 50 
hello 0
hello 1
hello 2
hello 3
hello 4
hello 5
hello 6
hello 7
hello 8
hello 9