中医的科学性:system()函数的疑问

来源:百度文库 编辑:高校问答 时间:2024/04/29 13:55:17
/*今有以下程序:*/
#include "stdio.h"
main()
{
char ip[15];
scanf("%s",&ip[15]);
system("ping %s",ip[15]);
}
/*我需要调用system()函数并用ping命令来
检测用户所输入的ip地址.但system()函数并不支持
附加.希望高手能帮忙解答以下用什么可以实现我得需要.谢谢!
在dev C++中能通过,但结果明显错误:
127.0.0.1
Ping request could not find host %s. Please check the name and try again.*/
Please

做出来了,看程序就明白了

#include <stdio.h>
#include <string.h>
#include <conio.h>

main()
{
char ip[15],ping[19];
scanf("%s",&ip);

strcpy(ping,"ping ");
strcat(ping,ip);

printf("%s",ping);
system(ping);
getch();
}

在另一个版答过了