c - Different array sizes -


this question has answer here:

when run following program, different array sizes. tired different ways result same, io doing wrong ?

#include<stdio.h>  void array_size(char *a[]) {     printf("func array size: %d\n", sizeof(a)); }  int main() {     char *str_array[]={"one", "two", "three"};      printf("array size: %d\n", (int)sizeof(str_array));      array_size(str_array);      return 0; } 

in function main str_array array 3 char *.

the parameter a of function array_size pointer. compiler not dynamically pass array length information when calling array_size.

the size of 1 pointer not equal size of 3 char * pointers.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -