⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list5-2.cpp

📁 这是c++编程方面的名著的例子代码
💻 CPP
字号:
// Listing 5-2// Demonstates the use of  execl// one of the family of exec( ) functions// used to spawn child processes// accepts a sequence of four integers that will be// passed to the program from list5-1#include <iostream.h>#include <strstream.h>#include <stdlib.h>#include <unistd.h>#include <string.h>void main(int argc, char *argv[]){    if(argc == 5){      char Argument[81];      strcpy(Argument,"");      strstream Buffer;      Buffer << "list5-1" << " ";      Buffer << (atol(argv[1]) * 2) << " ";      Buffer << (atol(argv[2]) * 3) << " ";      Buffer << (atol(argv[3])+ atol(argv[1])) << " ";      Buffer << atol(argv[4]) << ends;        Buffer >> argv[0];      Buffer >> argv[1];      Buffer >> argv[2];      Buffer >> argv[3];      Buffer >> argv[4];           cout << "Child Process Executes " << Buffer.str() << endl;           execvp("list5-1",argv);   }}

⌨️ 快捷键说明

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