我对编程还比较陌生,并决定在C中创建一个应急工具,作为Windows中常见问题的一个项目。此外,我想创建一个有不同问题的菜单,这些菜单应该是可选择的。
问题之一是无法到达服务器/客户端。然后在CMD中触发ping和跟踪。但我面临的挑战是,输入的每一个查询都无法获得一个单独的IP地址。结果也应该显示出来。有人知道吗?
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define buffer[BUFFER_SIZE] = { 0 };
int main()
{
int selection1;
printf("What is the problem? Type in the appropriate number and press Enter: \n");
printf("1) Something is unavailable.\n");
printf("2) Problem 2\n");
printf("3) Problem 3\n");
printf("4) Problem 4\n");
printf("5) Problem 5\n");
printf("6) Problem 6\n");
printf("7) Problem 7\n");
fflush(stdout);
scanf("%d", &selection1);
if (selection1 == 1)
{
fflush(stdout);
char* pingAdress;
scanf("%c", &pingAdress)
system( "ping %c", pingAdress)
}发布于 2022-11-25 15:11:31
下面是一个如何执行ping用例的示例。
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int selection1;
printf("What is the problem? Type in the appropriate number and press Enter: \n");
printf("1) Something is unavailable.\n");
fflush(stdout);
scanf("%d", &selection1);
if (selection1 == 1)
{
fflush(stdout);
char pingAdr[100], pingCmd[100];
printf("Enter host address: ");
scanf("%s", pingAdr);
sprintf(pingCmd, "ping -c 5 %s", pingAdr);
system(pingCmd);
}
return 0;
}https://stackoverflow.com/questions/74571341
复制相似问题