佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 856|回复: 8

C Language: 请大家帮我看下我做对了没有 [已解决]

[复制链接]
发表于 9-10-2008 04:14 PM | 显示全部楼层 |阅读模式
  1. /*
  2. Write a C program that declare one pointer type integer.
  3. The pointer must points to a variable type integer.
  4. Do not forget to give a value to the variable.
  5. Then, print the output.
  6. The output supposed to be just like the example below.

  7. *************************************************************************************
  8. e.g.

  9. The value for [put variable_name here] is = ???
  10. The value for [put pointer_name here] is = ???
  11. The value that [put pointer_name here] point to is = ???
  12. The memory address for [put variable_name here] is = ???
  13. The memory address for [put pointer_name here] is = ???

  14. *************************************************************************************

  15. ??? : are based on the value that u gave to the variable/based on your compiler
  16. */

  17. #include
  18. void main()
  19. {
  20. int year=100;
  21. int *pointer_to_year=NULL;

  22. pointer_to_year=&year;

  23. printf("The value for year is = %d.\n",year);
  24. printf("The value for pointer_to_year is = %d.\n",pointer_to_year);
  25. printf("The value that pointer_to_year points to is = %d.\n",*pointer_to_year);
  26. printf("The memory address for year is = %d.\n",&year);
  27. printf("The memory address for pointer_to_year is = %d.\n",&pointer_to_year);
  28. }
复制代码
我不是很确定
请大家帮我看一下
谢谢!

[ 本帖最后由 蜡笔小烦 于 18-10-2008 03:32 PM 编辑 ]
回复

使用道具 举报


ADVERTISEMENT

发表于 9-10-2008 04:20 PM | 显示全部楼层
#include <iostream.h>
int main()
{
int year=100;
int *pointer_to_year;

pointer_to_year=&year;

printf("The value for year is = %d.\n",year);
printf("The value for pointer_to_year is = %d.\n",pointer_to_year);
printf("The value that pointer_to_year points to is = %d.\n",*pointer_to_year);
printf("The memory address for year is = %d.\n",&year);
printf("The memory address for pointer_to_year is = %d.\n",&pointer_to_year);


return 0;
}
回复

使用道具 举报

 楼主| 发表于 11-10-2008 01:33 PM | 显示全部楼层
原帖由 AlexZana 于 9-10-2008 04:20 PM 发表
#include
int main()
{
int year=100;
int *pointer_to_year;

pointer_to_year=&year;

printf("The value for year is = %d.\n",year);
printf("The value for pointer_to_year is = %d.\n",pointer_to_ ...


不都一样吗?
除了这个<iostream.h>
什么分别呢?
回复

使用道具 举报

发表于 11-10-2008 01:50 PM | 显示全部楼层
你的code有没有拿去compile?
回复

使用道具 举报

 楼主| 发表于 11-10-2008 04:42 PM | 显示全部楼层
原帖由 糯米鸡 于 11-10-2008 01:50 PM 发表
你的code有没有拿去compile?


有啊~
可是看不出对不对

ps:
糯米鸡,我喜欢吃耶~

[ 本帖最后由 蜡笔小烦 于 11-10-2008 05:03 PM 编辑 ]
回复

使用道具 举报

发表于 11-10-2008 05:04 PM | 显示全部楼层

回复 2# AlexZana 的帖子

iostream 用 printf?

#include <stdio.h> 吧?
回复

使用道具 举报

Follow Us
 楼主| 发表于 11-10-2008 09:41 PM | 显示全部楼层
原帖由 onlylonly 于 11-10-2008 05:04 PM 发表
iostream 用 printf?

#include  吧?


iostream应该是C++的吧?
回复

使用道具 举报

发表于 11-10-2008 10:17 PM | 显示全部楼层

回复 7# 蜡笔小烦 的帖子

其实c 与 c++ 的分别不在于 iostream 与 stdio.h , 他们只是header file 罢了, c++ 可以用 iostream, 也可以用cstdio。

重要的是 syntax, 如 int function() 在c++ 是没有 argument, 在c 是可以接受任何的parameter。
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 12-10-2008 12:23 AM | 显示全部楼层
原帖由 onlylonly 于 11-10-2008 10:17 PM 发表
其实c 与 c++ 的分别不在于 iostream 与 stdio.h , 他们只是header file 罢了, c++ 可以用 iostream, 也可以用cstdio。

重要的是 syntax, 如 int function() 在c++ 是没有 argument, 在c 是可以接受任何的pa ...


好的
谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 22-12-2025 10:29 PM , Processed in 0.132322 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表