My OS is WIN7 64bit, using Code::Blocks 13.12!
it is part of my code:
76// printf("請輸入共有幾個小組:");
77// scanf("%u",&totalteam);
78// fflush(stdin);
79//
80// unsigned int *team = (int*) malloc( (totalteam + 2) * sizeof(int) );
81// team[0] = totalteam;
82// printf("現在要輸入小組的人數資料,\n要用問答的方式一組組輸入請按y,用檔案匯入請按其他。(y/其他)");
83// choice = getch();
84// printf("\n\n");
85//
86// if(choice == 'y')
87// {
It is line76 to line87
I wanted to skip many line of code, so I used Ctrl + Shift + C to make it as comment(about 300 lines)
but Build log show that:
C:\Users\user\Dropbox\座位表生成程式\main.c:76:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:77:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:78:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:79:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:81:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:82:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:83:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:84:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:85:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:161:1: error: expected expression before '/' token
etc...
It is not every line used // will be error.
If I compile this code in cmd (gcc main.c), it didn't show any error message.
I compiled other code which I used C:B 12.XX, it was no problem but now it cannot complie normaly.
what is the problem?
Thanks a lot!
Don't use C++ comments with C. You have to use proper C comments: /* */
(this is the first time I heard that // is not proper comment in C :o )
Does any way that we can adjust comment(ctrl + shift + C) and uncomment(ctrl + shift + X) from // to /* */?
I just want to skip some section of my code temporarily.
Quote from: gary8520 on January 31, 2014, 07:03:09 AM
Does any way that we can adjust comment(ctrl + shift + C) and uncomment(ctrl + shift + X) from // to /* */?
Mmh... I'm afraid this is not possible, but you could file a feature request.
Hence /* ... */ is different: You can comment large code sections like this:
/*
... large code section ...
... several lines of code ...
*/So you only need 4 characters to enter. :)
Quote from: MortenMacFly on January 31, 2014, 09:11:21 AM
Quote from: gary8520 on January 31, 2014, 07:03:09 AM
Does any way that we can adjust comment(ctrl + shift + C) and uncomment(ctrl + shift + X) from // to /* */?
Mmh... I'm afraid this is not possible, but you could file a feature request.
Hence /* ... */ is different: You can comment large code sections like this:
/*
... large code section ...
... several lines of code ...
*/
So you only need 4 characters to enter. :)
I have known that ::) , but there is several box comment and stream comment in my code, it cannot just work as comment(ctrl + shift + C) that whole section become comment
Thanks!
Quote from: gary8520 on January 31, 2014, 07:03:09 AM
(this is the first time I heard that // is not proper comment in C :o )
Compile for at least C99 to make them valid (gcc option --std=c99).
Quote from: gary8520 on January 31, 2014, 07:03:09 AM
I just want to skip some section of my code temporarily.
You may want to use
#if 0 to temporarily skip parts of the code:
#if 0
puts("this will be skipped"); /* comment */
...
#endif- osdt