Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Beginning with C and first problems  (Read 7535 times)

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

    Topic Starter


    Hopeful

    Thanked: 2
    Beginning with C and first problems
    « on: March 03, 2019, 05:44:41 AM »
    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: [Select]
    #include <stdio.h>

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

    I used Visual C++ 6 Portable and it reports error at compiling:
    Code: [Select]
    --------------------Configuration: ahoj - Win32 Debug--------------------
    Compiling...
    Error spawning cl.exe

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

    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


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Beginning with C and first problems
    « Reply #1 on: March 03, 2019, 07:44:05 AM »
    Quote
    Visual C++ 6 Portable
    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.
    I was trying to dereference Null Pointers before it was cool.

    MIRKOSOFT

      Topic Starter


      Hopeful

      Thanked: 2
      Re: Beginning with C and first problems
      « Reply #2 on: March 03, 2019, 11:47:51 AM »
      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