1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

C/C++ and Java

Discussion in 'Software Development' started by gfxrelay, Jul 25, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. gfxrelay

    gfxrelay Thread Starter

    Joined:
    Oct 26, 2005
    Messages:
    588
    Hola I am new to programming and was wondering if any one knows of a good IDE for C and C++. Also what sthe difference between VC++ and DEVC++?:confused:
     
  2. john56

    john56

    Joined:
    Jul 27, 2006
    Messages:
    1
    both vc++ and devc++ are good.
    I use notepad++ as a editor, and source insight as a source browser under Windows.
     
  3. fraq

    fraq

    Joined:
    Jul 27, 2006
    Messages:
    27
    Hi I was also wondering about that
     
  4. gfxrelay

    gfxrelay Thread Starter

    Joined:
    Oct 26, 2005
    Messages:
    588
    Hi thnx for the reply I was looking around and was wondering about C# would it be better to go of one shot and learn C# or rather go for C. Also is C# crossplatform?
     
  5. tobias2143

    tobias2143

    Joined:
    Jun 21, 2006
    Messages:
    11
    I wouldn't suggest learning C - just plain C - as a first language. There are lots of things that can go wrong, and the complier doesn't protect you, it will warn you, but won't stop you live Java will.
     
  6. gfxrelay

    gfxrelay Thread Starter

    Joined:
    Oct 26, 2005
    Messages:
    588
    Hola I thought so gonna taka a while but I think it will be better to learn c or C++ thnx for the reply (y)
     
  7. Shadow2531

    Shadow2531

    Joined:
    Apr 30, 2001
    Messages:
    2,636
    The DevC++ IDE uses the Windows port of the gcc collection. It's called Mingw.

    I use Mingw, but I use it without an IDE. I just type the code in a text editor, save it as a .cpp file and type the command to compile at the command line.

    If you want to use Mingw, you can gather all the files from the mingw site or you can just goto http://nuwen.net/mingw.html and get an already-made distro. This distro comes with the boost library. The boost_regex and boost_filesystem libs come with the distro. It also comes with openGL stuff and many tools for downloading from cvs and packing .exes etc. It supports Makefiles too and provides windres for create icon object files etc. If you get the Msys command shell from the mingw site, you can run configure scripts to generate Makefiles like you can on linux.

    To build a program, just fire up cmd.exe and do:

    g++ -Wall -Wextra file.cpp -o file

    , or you can optimize, strip, turn on extra warnings and pack the exe

    g++ -Wall -Wextra -ansi -pedantic file.cpp -o file -O3 -msse3 -mtune=i686 -s && upx --best file.exe

    If you want to build a program that uses boost_regex:
    g++ -Wall -Wextra file.cpp -o file -lboost_regex

    If you need to define something:

    g++ -Wall -Wextra file.cpp -o file --define _UNICODE

    It's quite nice using Mingw especially if you are use to linux as it also uses gcc and g++.

    There are a few things about Mingw that you might not like compared to the VC++ compiler.

    1. Mingw doesn't support wmain(), so you can't accept Unicode command line arguments in the normal way. You can add the suport yourself and rebuild mingw, but for now, you have to #include <windows.h>, define _UNICODE and use:

    int main() {
    int argc;
    wchar_t** argv = CommandLineToArgvW( GetCommandLineW(), &argc);
    }

    2. The Unicode c++ i/o stuff like wcout, wofstream, wifstream doesn't work. You have to use the unicode C functions like _wfopen() and fwprintf(). (Unless you install the STLPORT library, but that's a pain sometimes.)

    3. Even after stripping and packing, simple programs created with Mingw are large compared to vc++. As the program gets more complex, things even out though.

    4. If you get into directX stuff, you have to convert the directx libs for use with Mingw and then, not everything will work.

    Anyway, a simple c++ program:

    nametest.cpp
    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    
    int main() {
        string name;
        cout << "What is your name? ";
        getline( cin, name );
        cout << "Hello " << name << endl;
    }
    
    To build it with mingw:
    g++ -Wall -Wextra nametest.cpp -o nametest

    Then, just load up cmd.exe, cd to the directory that nametest.exe is in and type nametest and press enter.

    As for c#, it can be cross platform via the mone project.

    The vc++ IDE is the better ide than devc++, but it's also very heavy.

    You should NOT learn C stuff first. Learn modern c++ stuff first and then investigate c stuff later. When you learn c++ stuff you automatically learn a lot of C anyway.
     
  8. gfxrelay

    gfxrelay Thread Starter

    Joined:
    Oct 26, 2005
    Messages:
    588
    Hola thnx for the reply I actualy started with C this weekend and find it much easier then Java
    :D I was wondering though C++ uses the cout function where C uses printf but is the cin command equal to the scanf?:confused:
     
  9. Shadow2531

    Shadow2531

    Joined:
    Apr 30, 2001
    Messages:
    2,636
    In c++, you can also use C methods. For example, instead of including stdio.h, you include cstdio. Same goes for others like ctype.h --> cctype, string.h -> cstring etc.

    for example:
    Code:
    #include <cstdio>
    
    int main() {
        std::printf( "bla\n" );
    }
    
    scanf and cin are alike in that they both grab input from stdin, and printf and cout are alike in that they write to stdout, but they're technically not equal. scanf and printf are functions and cout and cin are class instances with many member functions that do different stuff.
     
  10. gfxrelay

    gfxrelay Thread Starter

    Joined:
    Oct 26, 2005
    Messages:
    588
    I managed to find a C++ demystified on the net. It seems a bit more diffucult then C but I guess I will be worth it rather learning C++ then C in the grand scale of things:D
     
  11. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/486163

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice