我一直在C語言程序設計中學習C語言中的朋友推薦的書。書名爲「C語言編程」由Stephen Kochan提供。感受一種被「C語言編程」困惑的書(Stephen Kochan)
我有一個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);'不需要 –