寻找爱的冒险里的漫画:c++程序调试不成功,错在哪里?

来源:百度文库 编辑:高考问答 时间:2024/05/04 20:10:53
#include " stdio.h"
#include " stdlib.h"
#include "Winsock2.h"
#include " iphelpapi.h"
Typedef DWORD (CALLBACK*PSARP) (
IPAddr DestIP, / /目的主机IP地址
IPAddr SrcIP, / / 源主机IP地址
PULONG pMacAddr, / / 返回的MAC地址
PULONG PhyAddrLen, / / 返回MAC地址的长度
addr) ; / /定义结构体
void main ( int argc, char**argv )
{
PSARP pSARP ;
HINSTANCE hInst; / /实例句柄
hInst =LoadLibrary( " iphelpapi.dll" ) ; / /加载IP Helper API所需的库文件
pSARP = ( PSARP) GetProcAddress ( hInst, " SendARP" ) ; / /获取SendARP函数的地址
/ /处理命令行参数
if ( argc ! = 2 )
{
printf ( " Get aMacAddress from host in a segment! \n" ) ;
printf ( "Usage: \n \GetMac. exe [Host IP] \n \n" ) ;
printf ( " Example: \n \GetMac. exe 192. 168. 0. 1 \n \n" ) ;
exit (0) ;
}
printf ( " \n IpAddress: % s\n" , argv[ 1 ] ) ;
int nRemoteAddr = inet_addr( argv[ 1 ] ) ; / /发送ARP查询包获得远程MAC地址
unsigned charmacAddress[ 6 ];
PULONG macAddLen = 6;
int iRet = pSARP ( nRemoteAddr,NULL, ( PULONG) &macAddress, &macAddLen) ;
if ( iRet = =NO_ERROR)
{
printf ( "MacAddress: " ) ;
for ( int i = 0; i < 6; i + + ) / /格式化输出获取的MAC地址
{
printf ( " %. 2x" ,macAddress[ i ] ) ;
if ( i < 5) p rintf ( " - " ) ;
}
}
else
printf ( " SendARP Error: % d \n" , GetLastError( ) ) ;
printf ( " \n" ) ;
}
格式先不要太在意

程序没具体看,不过开头的几个#include的头文件名里面的空格是怎么回事?stdio.h,stdlib.h,iphelpapi.h前面都多了个空格。