易截截图软件、单文件、免安装、纯绿色、仅160KB

[C] LINUX C 编程dup2问题


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>

void get_cal(const char *arg)
{
    char cmd[64];
    strcpy(cmd, arg);
 
    int pfds[2],bak_stdout;
    if(pipe(pfds)==0)
  { 
     
    printf("2\n");
    printf("fd_11 is %d\n",pfds[1]);     
    printf("2.1\n");
    bak_stdout=dup(1);
    printf("2.1.1\n");
    // close(1);
    printf("2.1.1.1\n");
      dup2( pfds[1], 1);     
      close(pfds[0]); 
      printf("1.2\n");
      system(cmd);
      close(pfds[1]);
      dup2(bak_stdout,1);
   

  else
    printf("pipe open error!\n");


void read_cal(char *data)
{
    char cmd[64], line[199]; 
    *data = 0;
    int pfds[2];
    if(pipe(pfds)==0)


相关问答:

急!C parser如何实现“__builtin_va_list”

最近在看一个用bison实现的C parser,OS是opensolaris。当用它来解析一个简单的hello.c时,出现“/usr/include/sys/va_list.h: parse error before __gnuc_va_list”。打开文件va_list.h后发现这样一行“typedef __bu ......

C 程序问题(四) - C/C++ / C语言

#include "stdio.h"
int main()
{
  char *ch(char *, char *);
  char str1[]="I am glad to meet you!";
  char str2[]="Welcom to study C!";
&nb ......

请教一题C,我看不明白! - C/C++ / C语言

#include "stdio.h"
void main()
{
  int *p;
  int a[10]={0,1,2,3,4,5,6,7,8,9};
  int k=0;
  p=a;
  for(int i=0;i<10;i++,p ......

linux下C语言开发oracle的问题。

两个文件1.PC,1.inc
1.PC有操作oracle数据库的 ,1.inc也有操作oracle数据库 
在其他数据中如informix 中$include 1.inc就可以使用了
在ORACLE数据库重 $include 1.inc不可用 EXEC SQL include 1.inc也不可 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号