Help with passing integer poniter to function
- From: "manochavishal@xxxxxxxxx" <manochavishal@xxxxxxxxx>
- Date: 1 Mar 2006 04:21:37 -0800
Hi,
I am having strange problem in my Program.
I cannot paste the whole program as it is huge so just pasting the
lines i think are necessary.
I am passing a integer array pointer to a function.
**********
int sockets[MAX_TCPCLIENTS]; /* an array of connected sockets*/
......
......
fprintf(stderr,"The value is %d",sockets);
accept_new_tcp_client(sockets,&readset,listenfd);
.......
.......
void accept_new_tcp_client(int *sockets, fd_set *readset, int listenfd)
{
struct sockaddr *signaddr;
int addrlength;
int i;
int clientsockfd;
addrlength = sizeof(signaddr);
fprintf(stderr,"\nThe value is %d",sockets);
/*== First accept the new connection ==*/
if((clientsockfd = accept(listenfd,(struct
sockaddr*)&signaddr,&addrlength))<0)
{
printf("\nSome Problem with accepting connection");
exit(EXIT_FAILURE);
}
fprintf(stderr,"\nAccepted a new Client connection");
fprintf(stderr,"\nThe value is %d",sockets);
********
The print output is
.....
The value is 12643936
The value is 12643936
Accepted a new Client connection
The value is 0Segmentation fault (core dumped)
Can anyone explians whats happening???
Cheers
Vishal
.
- Follow-Ups:
- Re: Help with passing integer poniter to function
- From: Keith Thompson
- Re: Help with passing integer poniter to function
- From: Nick Keighley
- Re: Help with passing integer poniter to function
- From: pemo
- Re: Help with passing integer poniter to function
- Prev by Date: Re: Memory Corruption Problem
- Next by Date: Re: how to do an infinite loop
- Previous by thread: Re: what is wrong with this
- Next by thread: Re: Help with passing integer poniter to function
- Index(es):
Relevant Pages
|