这个C 程序怎么会 什么都不输出。
C/C++ code:
]#include <unistd.h>
#include <signal.h>
#include <stdio.h>
int pid1,pid2;
int main( ) {
int fd[2];
char OutPipe[100],InPipe[100]; // 定义两个字符数组
pipe(fd); // 创建管道
while((pid1 = fork( )) == -1); // 如果进程1创建不成功,则空循环
if(pid1 == 0) {
lockf(fd[1],1,0); // 锁定管道
sprintf(OutPipe,"\n Child process 1 is sending message!\n");
write(fd[1],OutPipe,50); // 向管道写入数据
sleep(5); // 等待读进程读出数据
lockf(fd[1],0,0); // 解除管道的锁定
exit(0); // 结束进程1
}
else {
while((pid2 = fork()) == -1); // 若进程2创建不成功,则空循环
if(pid2 == 0) {
lockf(fd[1],1,0);
sprintf(OutPipe,"\n Child process 2 is sending message!\n");
write(fd[1],OutPipe,50);
sleep(5);
lockf(fd[1],0,0);
exit(0);
}
else {
wait(0); // 等待子进程1 结束
read(fd[0],InPipe,50); // 从管道中读出数据
相关问答:
最近突然想自己来实现一个五子棋程序,但不知道怎么开始,自己也没学画图形函数,能在控制台下直接写吗>>>?????
控制台?比图形界面更麻烦。
http://search.download.csdn.net/search/%E4%BA%94%E5%AD%90% ......
//C 接口
extern "C"
{
TESSDLL_API int __cdecl GetTessText(const char *imagefile, char *text);
}
//我在C#中声明
//调用C DLL 中的函数
[DllImport("OCRapi.dll&quo ......
请问用C或C++如何编写求解3D魔方的程序,该从何开始?
谢谢各位,帮忙提点建议吧。
http://www.mofang.net/code/176/182/6581.html
我只能突破60秒!唉。
我刚过40秒
google的android中有个OpenGL ES + ......
背景:
--------
头文件db_method.h经过美化后存在下面几种结构定义类型
typedef struct
{
BYTE id;
BYTE idAsync;
DM_T dmInfo;
CHAR tbName[MAX_TBNAME_LEN];
} REC ......
问题一:
在对齐为4的情况下
struct BBB
{
long num;
char *name;
short int data;
char ha;
short ba[5];
}*p;
p=0x1000000;
p+0x200=____;
(Ulong)p+0x200=____;
(char*)p+0x200=____;
假设在32位C ......