arraySize.cpp

#include <iostream> int sizeOfArray(int arr[]) { std::cout << "sizeOf array in func:" << sizeof(arr) << std::endl; std::cout << "sizeOf array[0] in func:" << sizeof(arr[0]) << std::endl; return sizeof(arr) / sizeof(arr[0]); } int main() { int arr[] = {1,2,3}; std::cout << "sizeOf array:" << sizeof(arr) << std::endl; std::cout << "sizeOf array[0]:" << sizeof(arr[0]) << std::endl; int numFromFunc = sizeOfArray(arr); std::cout << "sizeOfArray fun:" << numFromFunc << std::endl; return 0; }
c array size test

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.