|
查看: 857|回复: 8
|
C Language: 请大家帮我看下我做对了没有 [已解决]
[复制链接]
|
|
|
- /*
- Write a C program that declare one pointer type integer.
- The pointer must points to a variable type integer.
- Do not forget to give a value to the variable.
- Then, print the output.
- The output supposed to be just like the example below.
- *************************************************************************************
- e.g.
- The value for [put variable_name here] is = ???
- The value for [put pointer_name here] is = ???
- The value that [put pointer_name here] point to is = ???
- The memory address for [put variable_name here] is = ???
- The memory address for [put pointer_name here] is = ???
- *************************************************************************************
- ??? : are based on the value that u gave to the variable/based on your compiler
- */
- #include
- void main()
- {
- int year=100;
- int *pointer_to_year=NULL;
- 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);
- }
复制代码 我不是很确定
请大家帮我看一下
谢谢!
[ 本帖最后由 蜡笔小烦 于 18-10-2008 03:32 PM 编辑 ] |
|
|
|
|
|
|
|
|
|
|
发表于 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
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 11-10-2008 04:42 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 11-10-2008 05:04 PM
|
显示全部楼层
回复 2# AlexZana 的帖子
iostream 用 printf?
#include <stdio.h> 吧? |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 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。 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 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 ...
好的
谢谢 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|