+ 1
How to get the number of rows of a undeclared row String Array passed from another function as an argument.
This Code prints the row size of the string array correctly in the main() function but when the same string array is passed as an argument to another function named Strigify() the number of row printed in that function seems to be incorrect. So how to make it possible to get the exact row size of the string array which has been passed from another function as an argument? Thanks.... https://code.sololearn.com/cnk28SONH4I7/?ref=app
1 Resposta
+ 2
Primitive arrays types decay to the respective pointers when passed to a function. So as a result, "sizeof(value)" returns the size of a pointer(8 bytes here as of now). So the second expression is evaluated to be 8/255 which is 0(and so 0 is printed in the second line).
To overcome this, either pass the size of the array as an argument for the function, or use std::array(header "array") which don't decay to a pointer when passed to a function