linux中的return问题 - Linux/Unix社区 / 程序开发区
有一段创建消息队列的代码如下:
int creat_msg_queue()
{
key_t key;
int proj_id;
int msqid;
struct msqid_ds buffer;
proj_id=2;
key=ftok("/home/program",proj_id);
if(key==-1){
perror("cannot generate the IPC key");
return -1;
}
msqid=msgget(key,IPC_CREAT | 0660);
if(msqid==-1){
perror("cannot create message queue resource");
return -1;
}
printf("msqid=%d\n",msqid);
return msqid;
}
在该函数中我打印出的“msqid”的数值是32769
但是该函数的返回值却是0,这是为什么啊?
32769的二进制码是1000000000000001正好是0的补码。不过我解释不了,标记等待高人
C/C++ code:
#include <stdio.h>
# include <sys/ipc.h>
#include <sys/types.h>
#include <sys/msg.h>
#include <unistd.h>
int creat_msg_queue()
{
key_t key;
int proj_id;
int msqid;
struct msqid_ds buffer;
proj_id=2;
key=ftok("/home/program",proj_id);
if(key==
相关问答:
写了个测试程序如下
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......
引用内容vsking 2009-12-25 22:56:52
现在是win2008和iis8的时代了,不要还停留在iis5时代,win2008被评为十佳操作系统之首不是偶然的,你要是..
我的问题是:
最近想买个服务器,看了dell上的系统定制选择,一些 ......
如题,在WINDOWS底下的CODE会,但在LINUX下不知道如何实现,JS的代码应该是不一样的。 求教。
分不够再加。
http://topic.csdn.net/u/20100113/08/17ba1e71-4c33-43f6-91a5-0e031c86e5ed.html
linux ......
在ubuntu上搭建了服务器,根目录为/var/www,使用php脚本在/var/www/html文件夹下生成了文件夹和文件,生成的格式是/var/www/html/123456/sss.html,生成后查看html文件夹的权限是www-data,我执行php的删除脚本的时 ......
在ubuntu上搭建了服务器,根目录为/var/www,使用php脚本在/var/www/html文件夹下生成了文件夹和文件,生成的格式是/var/www/html/123456/sss.html,生成后查看html文件夹的权限是www-data,我执行php的删除脚本的时 ......