VSC++ Question

I want to use vsc++ for c programming but when i do the gui project it compiles with cpp so how can i foce it to use c files instead of c++ files


Answer this question

VSC++ Question

  • Larry McCay

    There is usually another problem. I've noticed that the IDE sets it to compile as cpp by default. If you go to project properties->configuration properties->c++->advanced->compile as and set it as default then you will be fine. Or if renaming all those cpp files to c is annoying then set it to compile as c code (/TC).

  • Robert Bigelow

    Note, that with very few exceptions, almost every C program can be compiled as C++. You can write a C program, even though it will be compiled as C++, and it will still work. For example, the Hello World program:

    #include <stdio.h>
    int main(void)
    {
    printf("Hello World!\n");
    return 0;
    }

    is both a C++ and C program. And for those few times where C and C++ do conflict, it's usually because the code is unsafe.

    #include <stdio.h>
    int main(void)
    {
    printf(L"Hello World!\n");
    // This code compiles under C, yet it has a fatal bug! If this was C++ you'll be told
    // exactly what the error is, and the compiler will not continue until you fix the bug.
    return 0;
    }

    If the compiler didn't warn you about the error, would you ever notice it Would you rather have this error crop up before you compile, or when it reaches your customer's machines

    If C++ prevents you breaking the 3rd commandment of C, why not use it Plus you get cool features like not having to declare variables at the top of your scope, dynamic allocators where you do not need to know sizeof() a type, exceptions, // comments, and structures which can have methods in them (okay those last two are in C too, but they're braindead versions).



  • Computing student

    Rename the extension the file's extension from .cpp to .c. But if you don't mind me asking, may I ask why you want to compile this in C and not C++



  • Nikas1

    Is stdio.h a exciting Header or a one from libary
    If it is from libary then change it to <stdio>
    I see your trying to make a Hello World Application.
    Your code should be like this.

    #include <iostream>
    using namespace std;
    int main()
    {
    cout << "Hello World!";
    return 0;
    }

    Hope this helps.

  • sridhar reddy mitapalli

    well im learning C for right now cause its simplier than moving to C++

  • VSC++ Question