Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

C++ a lil help

Rawdawg92

New Coder
Just starting to get back to programming. i did it awhile back but have forgotten a lot. i have Visual Studios . Windows 10. i'm working off a laptop . I have a SamsTeachYourself book . chapter 1 is trying to teach you how to compile a basic executable. what am i doing wrong? i wrote the code exactly like it says in the book and installed several extensions . Please help . it also so g++ is not supported?
 

Attachments

  • question2.png
    question2.png
    117.1 KB · Views: 5
Hey there.

First of all, that isn't Visual Studio. That's Visual Studio Code, which isn't a full-fledged IDE. If you're working with VSCode, you'll have to download a crap ton of extensions and do some of your own configuring to get a language like C++ working. And to be honest, I wouldn't go through the bother of doing all of that.

If you're going to be writing C or C++ code on Windows, download an IDE like Code::Blocks or Visual Studio. For Code::Blocks, you'll need to set-up a utility called MinGW, which will grant you the ability to compile C and C++ programs on Windows. Visual Studio on the other hand, comes with its own C++ compiler, so you won't have to do any configuring of your own(When you do install Visual Studio, I believe that you need to download the C++ extension for it. I can't remember as I don't use Visual Studio anymore).

For MinGW, as stated, you're going to have to set it up yourself. That includes installation and setting-up the PATH variables. There are tutorials online on how to set this all up, so I won't be going over it. When you have set-up MinGW, you will have GCC(GNU Compiler Collection) installed then. This gives you access to both gcc for C files and g++ for C++ files. Again, this is only after you've set-up MinGW.

Once you're done setting it up and you've got it assigned to your PATH variables, you should now be able to compile your code. If you use Code::Blocks, then you'll need to assign the compiler to Code::Blocks. Again, there are tutorials on how to do that. Visual Studio, again, comes with its own compiler.

If you're on an OS X system, it should have came with Apple's own Clang compiler. Try opening-up a terminal and use Clang to compile your C++ file. There are tutorials online on how to use Clang, so search up on how to use it.

If you're on a GNU/Linux system(Such as Debian, Ubuntu, Fedora, etc.) then it will have definitely came with GCC. This comes with both a C and a C++ compiler. For C, you just use: gcc <filename.c>. For C++, you use: g++ <filename.cpp>. GCC is quite powerful, so if you are on GNU/Linux, use it. Plus, it comes pre-installed, so you won't have to download anything. You'll just get periodic updates every so often, so be sure to apply those updates too.

Hope this helps.
 

New Threads

Buy us a coffee!

Back
Top Bottom