Pass in a variable by reference to receive the number of elements you read?
Code:
simbol* alfabet( FILE* fisier, unsigned int &numElements)
{
// Set numElements in here
}
int main()
{
unsigned int numElements = 0;
simbol *s = alfabet(filePtr, numElements);
}
Hope you're dynamically allocating the memory for that pointer in the function, or you will lose whatever it's pointing to when you leave the function.
Also, there's no indication that this is actually a C++ program, as all you show is the use of FILE, which is C I/O. If you're actually writing C, then you need to pass a pointer to the argument as C does not support pass-by-reference:
Code:
simbol* alfabet( FILE* fisier, unsigned int *numElements)
{
*numElements = numRead;
}
int main()
{
unsigned int numElements = 0;
simbol *s = alfabet(filePtr, &numElements);
}