Software > Computer programming

Beginning with C and first problems

(1/1)

MIRKOSOFT:
Hi!

I began learning C and at first example "Hello world!" compilation returns error.
I have no problem with programming at all - I know assembler of some 8/16-bit computers, Basic and Visual Basic.

This is code of ahoj.c:

--- Code: ---#include <stdio.h>

main()
{
printf("Ahoj svet!\n");
}
--- End code ---

I used Visual C++ 6 Portable and it reports error at compiling:

--- Code: -----------------------Configuration: ahoj - Win32 Debug--------------------
Compiling...
Error spawning cl.exe

ahoj.obj - 1 error(s), 0 warning(s)
--- End code ---

Then I tried VS Code Portable and there at syntax highlighting reports this:



What do I wrong?

Thank you all for help me in World of C.
Miro

BC_Programmer:

--- Quote ---Visual C++ 6 Portable

--- End quote ---
There is no "Visual C++ 6 Portable" so whatever you are using is aftermarket. Anyway, cl.exe needs to be in the list of "Executable directories" found under tools->Options. That might be set per-machine with this "aftermarket" thing, or maybe it merely needs configured.

This is the same thing the VS Code error is indicating you should do. You need to add the include directory to the c_cpp_properties.json file.

.C is the file extension for C files. .cpp is for C++ files. this is relevant because what you have there is in a CPP file but is not valid C++ code, so you'd want to use the .C file extension so that the compiler knows it is a C file. In C you could omit the return type of the main() routine but in C++ you have to specify it.

MIRKOSOFT:
Thank you!

I configured paths and my code in Visual C++ 6 Portable works.
Really it is portable VC++ - no install only extract and now I know that configure....

How to configure VSCode Portable don't know.
Miro

Navigation

[0] Message Index

Go to full version