I have
run(){
...
struct sockaddr_in from;
int i = recvpacket(buffer,from, fromlen)
...
}
recvpacket(char *buffer, struct sockaddr_in from, int fromlen)
{
//udp recvfrom stores the address of the sender in from
}
I get the following runtime Error in VC++
runtime check failure - the variable 'from' is used without being initialized
should I pass by reference, how should I do that?
Two things to fix:
to remove the warning you have to initialize
fromlike this for example:struct sockaddr_in from= {0};to get the address when calling
recvpacketyou have to declare it as by referencerecvpacket(char *buffer, struct sockaddr_in& from, int fromlen)