我一直在通过一个朋友推荐的书籍自学C语言编程。这本书的名字是Stephen Kochan的"Programming in C"。
我有Java编程背景,在阅读Stephen的书时,我对其中编写代码的方式感到有些困惑。例如下面的代码,我在评论中表达了我的疑惑。也许我错过了一些重要的东西,所以我想听听大家对在C中编写代码的正确方法的看法。
#include <stdio.h>
void test(int *int_pointer)
{
*int_pointer = 100;
}
int main(void)
{
void test(int *int_pointer); // why call the test() function here without any real argument? what's the point?
int i = 50, *p = &i;
printf("Before the call to test i = %i\n", i);
test(p);
printf("After the call to test i = %i\n", i);
int t;
for (t = 0; t < 5; ++t) // I'm more used to "t++" in a loop like this. As I know ++t is different than t++ in some cases. Writting ++t in a loop just drives me crazy
{
if (4 == t) // isn't it normal to write "t == 4" ?? this is driving me crazy again!
printf("skip the number %i\n", t);
else
printf("the value of t is now %i\n", t);
}
return 0;
}
void test(int *int_pointer);
。 - γηράσκω δ' αεί πολλά διδασκόμε