c pipe
来源:互联网 发布:淘宝速捷运动专营店 编辑:程序博客网 时间:2024/05/21 10:36
popen like fopen , wirte shell result
#include "stdio.h"
#include "stdlib.h"
main () {
int ret;
FILE *fileptr=NULL;
char ipfile[512];
char ibuf[512];
char os[512];
char osname[512];
int i;
fileptr = popen("hostname", "r");
memset (ipfile,0x00,sizeof(ipfile));
memset (ibuf,0x00,sizeof(ibuf));
memset (os,0x00,sizeof(os));
memset (osname,0x00,sizeof(osname));
if (fileptr == NULL) {
printf ("open file fail \n");
return;
}
while (fgets(ibuf,sizeof(ibuf),fileptr)!=NULL) {
if (1 != sscanf(ibuf,"%s",&os)) {
printf ("read file fail \n");
}
printf ("line30:ibuf=%s\n",ibuf);
}
for (i=0;ibuf[i]!='\0';i++) {
if (ibuf[i]==' ') {
break;
} else {
printf ("line35:ibuf[%d]=%c \n",i,ibuf[i]);
osname[i]=ibuf[i];
}
}
printf ("osname=%s\n",osname);
pclose(fileptr);
}
- c pipe
- scull-pipe.c
- Beginning C stdin pipe programming
- Linux C编程 - 管道pipe
- pipe 函数 (C语言)
- pipe 函数 (C语言)
- Linux C编程 - 管道pipe
- pipe()
- pipe
- pipe
- pipe
- pipe
- PIPE
- pipe
- pipe
- pipe
- pipe
- pipe
- c#读取INI文件
- 选择排序
- 关于cocos2d-x中CCScrollView和CCMenu触摸优先级的解决方案
- Hadoop中自定义计数器
- 线段树 poj3468
- c pipe
- C# WinForm 如何实现程序重启?
- how to remove submodule in git
- Adapter简单用法
- TomCat服务器,as3客户端,java服务器,外网访问
- iOS杂谈12—iOS面试题汇总(一)
- Linux下Tomcat死活找不到JSP页面中import指定类的解决方法
- ubuntu 12.10 软件源(163 Source)
- mysql5.5 启动报错:File './mysql-bin.index' not found (Errcode: 13)