c語言校驗mac函數(shù) c++校驗和

菜鳥C語言編程判斷IP MAC地址是否合法

可以試一下

創(chuàng)新互聯(lián)致力于互聯(lián)網(wǎng)品牌建設(shè)與網(wǎng)絡(luò)營銷,包括成都做網(wǎng)站、成都網(wǎng)站建設(shè)、SEO優(yōu)化、網(wǎng)絡(luò)推廣、整站優(yōu)化營銷策劃推廣、電子商務(wù)、移動互聯(lián)網(wǎng)營銷等。創(chuàng)新互聯(lián)為不同類型的客戶提供良好的互聯(lián)網(wǎng)應(yīng)用定制及解決方案,創(chuàng)新互聯(lián)核心團隊10多年專注互聯(lián)網(wǎng)開發(fā),積累了豐富的網(wǎng)站經(jīng)驗,為廣大企業(yè)客戶提供一站式企業(yè)網(wǎng)站建設(shè)服務(wù),在網(wǎng)站建設(shè)行業(yè)內(nèi)樹立了良好口碑。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

#include stdio.h

int checkIP(const char* p)

{

int n[4];

char c[4];

if (sscanf(p, "%d%c%d%c%d%c%d%c",

n[0], c[0], n[1], c[1],

n[2], c[2], n[3], c[3])

== 7)

{

int i;

for(i = 0; i 3; ++i)

if (c[i] != '.')

return 0;

for(i = 0; i 4; ++i)

if (n[i] 255 || n[i] 0)

return 0;

return 1;

} else

return 0;

}

int main()

{

const char* x[] =

{

"192.168.1.1",

"10.0.0.1.",

"127.256.0.1",

"iugerjiogjioe",

"172.16,0.1",

};

const char* m[] =

{

"不是合法的IP地址",

"是合法的IP地址"

};

int i = 0;

while(x[i] != 0) {

printf("%s %s\n", x[i], m[checkIP(x[i])]);

++i;

}

return 0;

}

查詢MAC地址的C語言代碼…要求簡單精煉!

#include windows.h

#include wincon.h

#include stdlib.h

#include stdio.h

typedef struct _ASTAT_

{

ADAPTER_STATUS adapt;

NAME_BUFFER NameBuff [30];

}ASTAT, * PASTAT;

ASTAT Adapter;

void main (void)

{

NCB ncb;

UCHAR uRetCode;

char NetName[50];

memset( ncb, 0, sizeof(ncb) );

ncb.ncb_command = NCBRESET;

ncb.ncb_lana_num = 0;

uRetCode = Netbios( ncb );

printf( "The NCBRESET return code is: 0x%x \n ", uRetCode );

memset( ncb, 0, sizeof(ncb) );

ncb.ncb_command = NCBASTAT;

ncb.ncb_lana_num = 0;

strcpy( (char*)ncb.ncb_callname, "* " );

ncb.ncb_buffer = (unsigned char *) Adapter;

ncb.ncb_length = sizeof(Adapter);

uRetCode = Netbios( ncb );

printf( "The NCBASTAT return code is: 0x%x \n ", uRetCode );

if ( uRetCode == 0 )

{

printf( "The Ethernet Number is: %02x%02x%02x%02x%02x%02x\n ",

Adapter.adapt.adapter_address[0],

Adapter.adapt.adapter_address[1],

Adapter.adapt.adapter_address[2],

Adapter.adapt.adapter_address[3],

Adapter.adapt.adapter_address[4],

Adapter.adapt.adapter_address[5] );

}

}

如何用C語言獲取網(wǎng)卡的mac地址

為什么一定要用C語言呢?這個用C語言比較麻煩,需要的知識比較多,完全可以用更簡單的辦法啊。命令行上這樣的命令“ipconfig -all | find "物理地址"”,可以很簡單的就得到了。

如果是英文系統(tǒng), 將“物理地址”換成“Physical Address”即可。

如果非的要用C語言,則可以先調(diào)用system函數(shù), system("ipconfig -all | find \"物理地址\" temp.txt" ); 將mac地址信息存入臨時文件temp.txt;然后再從中提取。

文章標題:c語言校驗mac函數(shù) c++校驗和
分享URL:http://bm7419.com/article24/ddccgce.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站企業(yè)網(wǎng)站制作、標簽優(yōu)化、軟件開發(fā)、網(wǎng)站改版定制開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計