Menu

simple 1st time code i feel so stupid

TYRRAM
2008-07-25
2012-09-26
  • TYRRAM

    TYRRAM - 2008-07-25

    i started to learn c today and it my first ever attempt so i followed these directions http://en.wikibooks.org/wiki/C_Programming in wiki books i downloaded dev-c, crimson editor and cygwin so the directions go: in crimson editor or note pad copy and paste

    include <stdio.h>

    int main()
    {
       printf("Hello, world!\n");
       return (0);
    }
    its the simple hello world command right ?? not so so i save it to my home folder in cygwin and i open cygwin and type ls and get home.c all is well then type gcc -o hello hello.c to compile and i get gcc: command not found over and over i once didnt but still didnt get hello.c hello.exe either so it wont compile. What am i doing wrong here ?? and can i do it with a better prog like dev-c or visual studio is it the prog im using or am i missing some glaring fact here please help i really want to learn this stuff. thx

     
    • cpns

      cpns - 2008-07-25

      > dev-c, crimson editor and cygwin

      Why did you do all that? Dev-C++ is an editor (arguably crimson is better), and comes (as an option) with the MinGW/GCC toolchain, making Cygwin unnecessary. Moreover Cygwin is likely to interfere with your MinGW installation. Unless you specifically want to work with Linux compatible source code and development work-flow, I suggest that you avoid Cygwin like the plague!

      To be honest I would no longer recommend anyone use these tools for learning. You need a good debugger to really help you understand how code works, and these tools don't have a good debugger (or at least not a usable graphical interface to GDB which is a good debugger but horrible to use). I would also not recommend learning C either instead of, or as a stepping stone to C++.

      I would indeed recommend Visual C++, especially since it is now free: http://www.microsoft.com/express/vc/ . However in using Visual Studio the underlying operations in building an application are somewhat hidden from you, which depending on how you look at it, is either one less thing to worry about, or a solid foundation that you will miss out on. Personally I'd go with the productivity and avoid the pain - at least for the time-being.

      If you do want something less monolithic than Microsoft's tools, I'd still recommend Dev-C++ over Cygwin, and the MinGW toolchain is the same GNU compiler except it does not require Cygwin's clunky Linux emulation to run. By setting the PATH environment variable appropriately, you can even run MinGW's gcc from the command line just like in your tutorial (except from the windows command line rather than bash). If you want MinGW separately from Dev-C++, see www.mingw.org.

      The PATH environment variable setting is probably the cause of the problems you are currently having.

      Clifford

       
    • TYRRAM

      TYRRAM - 2008-07-25

      ok do u have a site that gives step by step direction for coding and compiling in visual studio ? a beginners guide i can write the code in vs but i don't know how to compile or even if it compiles.

       
      • cpns

        cpns - 2008-07-25

        Well this is hardly the forum for that! Did you try: http://msdn.microsoft.com/en-us/beginner/default.aspx ?

        To get to the point where you can enter the code in the tutorial you are using:

        1) File->New->Project
        2)Project type: Visual C++->Win32, Template: Win32 Console Application
        3) Enter a name for the project, uncheck the "Create directory for solution" box, Change the location is you wish.
        4) Click OK
        5) Click Next
        6) Select "Empty project"
        7) Unslelect "Precompiled Headers"
        8) Click Finish
        9) In the "Solution explorer", right-click->Add->New Item->C++ file
        10) give it a name
        11) click Add
        12) If you want C compilation, right click teh file in "Solution explorer", and rename it with a .c extension.
        13) Enter the code
        14)To run the code, Ctrl+F5, to debug it F5 (Set breakpoints in teh left margin).

        Clifford

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.