发布网友 发布时间:2022-04-22 07:40
共2个回答
热心网友 时间:2022-06-17 21:58
#include "stdio.h"
#include "conio.h"
main()
{
int i,j;
char ip[20];
char temp[100];
char ch='\0';
FILE *fp;
system("ipconfig >d:\\myip.txt");
if ((fp=fopen("d:\\myip.txt","r"))==NULL)
{
printf("the file can not open:\nPress any key to exit:");
getch();
exit(1);
}
for (i=0;i<7;i++)
{fgets(temp,80,fp); /*跳过一些行*/
/*printf("%s\n",temp); */}
fgets(temp,80,fp);
i=0;j=0;
while (temp[i++]!=':')
;
while (temp[i]!='\n')
ip[j++]=temp[i++];
ip[j]=0;
printf("IP=%s\n",ip);
fclose(fp);
system("del d:\\myip.txt");
getch();
}
热心网友 时间:2022-06-17 21:58
能