Hi, I'm getting the following error:
Error 1 error C2065: 'szGatewayServer' : undeclared identifier
This is the line where the error is occuring:Code:#define SERVER "test" struct sTransactionDetails { char szGatewayServer[70]; }; int ConnectToGateway(int sockfd, char * szGatewayServer); int main(void) { int sockfd; struct sTransactionDetails txnDetails; memset(&txnDetails, 0, sizeof(txnDetails)); sockfd = CreateSocket(); strncpy_s(txnDetails.szGatewayServer, sizeof(txnDetails.szGatewayServer), SERVER, strlen(SERVER)); ConnectToGateway(sockfd, txnDetails.szGatewayServer); return 0; } int ConnectToGateway(int sockfd, char * szGatwayServer) { struct sockaddr_in hints; int state; struct hostent * hostStruct; char ** palias; hostStruct = gethostbyname(szGatewayServer); for (palias = hostStruct->h_addr_list; *palias != 0; palias++) printf("Host: %s\n", *palias); state = connect(sockfd, (const struct sockaddr *)&hints, sizeof hints); if (state == SOCKET_ERROR) return SOCKET_ERROR; return 0; }
I don't understand why I'm getting this error... It's more than likely something stupid I can't see but I've been searching for it for like 30 minutes now... Any ideas?Code:hostStruct = gethostbyname(szGatewayServer);
I've chopped out lots of unnecessary code to try and make it easier to read.
Thanks.



LinkBack URL
About LinkBacks



Thanks tabstop!