prueba.c

来自「rtlinux-3.2源码」· C语言 代码 · 共 38 行

C
38
字号
/******************************************************************************//* This file has been written by Sergio Perez Alca駃z <serpeal@upvnet.upv.es> *//*            Departamento de Inform醫ica de Sistemas y Computadores          *//*            Universidad Polit閏nica de Valencia                             *//*            Valencia (Spain)                                                *//*                                                                            *//* The RTL-lwIP project has been supported by the Spanish Government Research *//* Office (CICYT) under grant TIC2002-04123-C03-03                            *//******************************************************************************/#include <stdlib.h>#include <unistd.h>#include <time.h>int main(int argc, char *argv[]) {  int i;  int max_iterations = 1000;  struct timespec time;  char tcporder[]="./tcpClient 158.42.58.141 Hello_baby";  char udporder[]="./udpClient 158.42.58.141 Hello_baby";  char command[60];  time.tv_sec = 0;  time.tv_nsec = 50000;  if(argc == 2)    max_iterations = atoi(argv[1]);  for(i=0; i< max_iterations; i++){    sprintf( &command[0],"%s%d %s", tcporder, i, "> /dev/null");    if(system(&command[0])==-1) break;    sprintf( &command[0],"%s%d %s", udporder, i, "> /dev/null");    if(system(&command[0])==-1) break;  }  return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?