标签:文件 span common quit mon stream nbsp sha 产生
1.system()函数
头文件 #include <stdlib.h> 函数定义 int system(const char * string);
函数说明:通过linux命令 man 3 system 可以看到该函数的作用是:执行shell命令
system()会调用fork()产生子进程,由子进程来调用/bin/sh-c string来执行参数string字符串所代表的命令。此命
令执行完后随即返回原调用的进程。在调用system()期间SIGCHLD 信号会被暂时搁置,SIGINT和SIGQUIT 信
号则会被忽略。
实例说明:
比如需要将一些文件拷贝到另一个目录
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char* argv[])
{
std::string cp_txt_commond = "/bin/cp -f ";//-f:覆盖已经存在的目标文件而不给出提示
cp_txt_commond += "*.txt ";
cp_txt_commond += "dir/";
printf("cp_txt_commond result :%d" ,system(cp_txt_commond.c_str() ));
return 0;
}
标签:文件 span common quit mon stream nbsp sha 产生
原文地址:https://www.cnblogs.com/zhaobinyouth/p/13796412.html