Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > C/C++ > 奇怪的返回:ask :ask
【标  题】:奇怪的返回:ask :ask
【关键字】:ask,ask
【来  源】:http://blog.chinaunix.net/article.php?articleId=46416&blogId=761

奇怪的返回:ask :ask

Your Ad Here
test.h是我写的一个函数吧(不知道是不是)
请看:
linux# gcc test1.c
linux# ./a.out
-1073743380
linux# cat test1.c
#include <test.h>
main()
{
int a=2,b;
b=pri(a);
printf("%d\n",b);
}


linux# cat /usr/include/test.h
pri()
{int x;
return x;
}

linux#
我就只是返回了x 怎么会打印出一个奇怪的数 我的要求是只返回x的值。

pri()

???

return pro()

什么类型。。。。。
pri() /* 应该有返回值 如: int pri(int a)
{int x; /* 这个x没有初始化,值是不一定的 */
return x;
}

而且,你把test.h放在/usr/include下面实在是奇怪,应该放在test.c同一目录下,在test.c里用 #include "test.h" 包含这个文件
另外,一般 .h 文件是不包含函数定义的,只有函数声明

不知道你正在学C语言的哪一部分,在试验什么特性
如果没有指定的话
c中默认表示返回int值
谢谢,刷新就多了无版主的回贴了。呵呵~~~

学到了函数,我看见/usr/include/*里文件全是英文的,我就想自已写个试试有同样的效果吗?

我要返回X的值,小妹很莱,不懂怎么写。请问具体怎么写
在同一目录下写3个文件,
test.h
代码:
#ifndef TEST_H
#define TEST_H

int pri(int);

#endif /* TEST_H */

test.c
代码:
#include "test.h"

int
pri(int a)
{
  return(a * 2);
}

main.c
代码:
#include <stdio.h>
#include "test.h"

int
main(void)
{
  int x;

  x = pri(5);
  printf("x = %d\n", x);

  exit(0);
}

用 gcc main.c test.c -o test 编译
一个随机函数的程序,不知道错在哪里?:【上一篇】
关于open()`不懂的地方。:【下一篇】
【相关文章】
  • Script to get network number and broadcast address from ip and mask
  • 提问的智慧(How To Ask Questions The Smart Way)
  • 关于umask
  • 一个非常有用的命令tasklist
  • Change the subnet mask of an interface
  • ES222:chapter7-state database(tasks)
  • ES222:chapter9-RAID-0 volumes(tasks)
  • ES222:chapter11-RAID-1(mirror)volumes(tasks)
  • ES222:chapter13-soft partitions(tasks)
  • ES222:chapter15-RAID-5 volumes(tasks)
  • 【随机文章】
  • Linux 程序设计入门-crypt
  • Python
  • 蠕虫病毒“高波”变种分析报告(2)
  • 用CD色彩样式批量调色
  • 三种Web开发主流技术的评价之ASP
  • 将Excel表格内容直接转换成图片
  • Sun Solaris 10系统DTrace的使用方法
  • 在Linux下如何驱动D-link DFE-530TX(最终稿)
  • 触发器中调用远程链接的数据库的配置方法
  • 用fcntl设定socket为非阻塞
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.