Pass struct array to function
How would I go about making this work I seem to have hit a wall. Also I REALLYYYY don't want to use a global struct (tisktisk). Thanks
void playerslist(int qnum);
void q1(){} //No content right now but wouldn't matter anyway
void playerslist(int qnum){
struct playerbase{}
playerbase * player=new playerbase [];
q1(); //What would I do here to pass *player to q1(); ?
}
Re: Pass struct array to function
Do you mean
Code:
void q1(struct playerbase* pPlayerBase)
{
}
?
Re: Pass struct array to function
since op is using new, not free, I will assume this is C++ and not C: There is no need for struct keyword in signature.
Code:
void func( ClassName* pClassName)
{
}
void foo()
{
ClassName* ptr = new ClassName;
func(ptr);
}
Having said that, it is a very rare occurrence that anyone should be using new[] instead of e.g. QList or std::vector/queue.