User forums > Using Code::Blocks
don't compile a small Cpp language with Code::Block
(1/1)
iop184:
I am a freshman about Code::Block. I can run the code by itself in the Code::Block, produce ''Hello world!''. However, don't run the small code, as follow:
--- Code: ---main()
{
int i,j,k;
printf("\n");
for(i=1; i<5; i++)
for(j=1; j<5; j++)¡¡
for (k=1; k<5; k++)
{
if (i!=k&&i!=j&&j!=k)
printf("%d,%d,%d\n",i,j,k);
}
}
--- End code ---
The Block Log says that:
--- Code: ---mingw32-g++.exe -c ji.cpp -o ji.o
ji.cpp:6:9: error: stray '\302' in program
for(j=1; j<5; j++)隆隆
^
ji.cpp:6:9: error: stray '\241' in program
ji.cpp:6:9: error: stray '\302' in program
ji.cpp:6:9: error: stray '\241' in program
ji.cpp: In function 'int main()':
ji.cpp:4:16: error: 'printf' was not declared in this scope
printf("\n");
^
Process terminated with status 1 (0 minute(s), 0 second(s))
5 error(s), 0 warning(s) (0 minute(s), 0 second(s))
-------------- Run: Debug in xz (compiler: GNU GCC Compiler)---------------
Checking for existence: C:\Users\Administrator\Desktop\xz\bin\Debug\xz.exe
Executing: "C:\CodeBlocks/cb_console_runner.exe" "C:\Users\Administrator\Desktop\xz\bin\Debug\xz.exe" (in C:\Users\Administrator\Desktop\xz\.)
Process terminated with status -1073741510 (0 minute(s), 2 second(s))
-------------- Run: Debug in xz (compiler: GNU GCC Compiler)---------------
Checking for existence: C:\Users\Administrator\Desktop\xz\bin\Debug\xz.exe
Executing: "C:\CodeBlocks/cb_console_runner.exe" "C:\Users\Administrator\Desktop\xz\bin\Debug\xz.exe" (in C:\Users\Administrator\Desktop\xz\.)
Process terminated with status -1073741510 (0 minute(s), 1 second(s))
--- End code ---
I have no idea about this! Could you tell me how can run the small code correctly?
BlueHazzard:
1) never send me a private message with the same question... Please post it in the forum...
2) you have still a mall encoding or you add some cryptic unicode characters to your file. as you can see in the build log, gcc finds some cryptic Japanese characters at the end of the for loop. You have to remove them...
2.1) to fix the encoding Edit->File Encoding-> ASCHII or UTF-8 . Now delete all malformed characters
3) You don't have included stdio (if you are compiling only c code,what you code is at the moment, please use the file extension .c not .cpp)
greetings
ollydbg:
--- Quote ---ji.cpp:4:16: error: 'printf' was not declared in this scope
printf("\n");
--- End quote ---
You need to at least add some include headers. But I think this is a C language related question, you can asked such questions on C Board - Cprogramming .com.
iop184:
Hello, BlueHazzard and ollydbg! The bug is resolved by your suggestions. Thank you very much!
Navigation
[0] Message Index
Go to full version