The function cannot initialize an array because sizeof() returns bytes of an int pointer
not the size the memory pointed by myArray.
void assignArray(int *myArray)
{
for(int k = 0; k < sizeof(myArray); ++k)
{
myArray[k] = k;
}
}
Are there other problems ?
Thanks
I don’t see other problems. However, you probably wanted this:
Unless, of course, even the compiler doens’t know how big it is at compile time. In which case you have to pass a size explicitly.
If you don’t know the size, you have a design error.
http://codepad.org/Sj2D6uWz