#include <stdio.h>
#include <string.h>
#include "include.h"
#include "windows.h"
#include "stdio.h"


int ExternalIP(SOCKET Sock, char *szChannel)
{
DWORD dwRet = 0;
HANDLE hHandle;
char szIP[16] = {0};
char szTempPath[MAX_PATH] = {0};
char szTempFile[MAX_PATH] = {0};
char szSendBuffer[512] = {0};
if (!szChannel)
return false;

GetTempPath(sizeof(szTempPath) - 1, szTempPath);
GetTempFileName(szTempPath, "Temp", 0, szTempFile);
// if (URLDownloadToFile(NULL, "http://www.whatismyip.org", szTempFile, 0, NULL) == S_OK)

if (NULL, "http://www.whatismyip.org", szTempFile, 0, NULL)
{
hHandle = CreateFile(szTempFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hHandle != INVALID_HANDLE_VALUE)
{
ReadFile(hHandle, szIP, sizeof(szIP) - 1, &dwRet, NULL);
snprintf(szSendBuffer, sizeof(szSendBuffer) - 1, "Main-> External IP: %s", szIP);
/* IrcMsg(Sock, "PRIVMSG", szChannel, szSendBuffer);
irc_privmsg(Target, "Main-> External IP: %s", szIP);*/
CloseHandle(hHandle);
}
}
return 0;
}

Dear Users

Can anyone help me i try to compile my external ip but i got 1 error, can anyone help me to resolve this problem
thanks.



i got this errot:

Compiling...
external_ip.cpp
c:\documents and settings\icemann\desktop\work_fix_me2\external_ip.cpp(29) : error C3861: 'snprintf': identifier not found

i type the () but again the same error
snprintf()(szSendBuffer, sizeof(szSendBuffer) - 1, "Main-> External IP: %s", szIP);
/* IrcMsg(Sock, "PRIVMSG", szChannel, szSendBuffer);

yes but is i type _snprintf i receive then 88 errors and 1 warning?

yes but is i type _snprintf i receive then 88 errors and 1 warning?

That might be good, that might be bad. If only I had enough context to tell.

With the code you posted, removing the inclusion of the unavailable header file "include.h", I get no errors or warnings with either snprintf or _snprintf when using gcc in non-standard mode.

This article has been dead for over six months. Start a new discussion instead.