Saturday 19 March 2011

Your first program in C

Well for anyone who actually reads these, and has an interest for programming. But was never quite sure how to begin. I will go step by step and show you how to begin. Most tutorials on the internet you read shows you the coding. But never shows you anything past that in terms of how to compile(build it), and where to write it(environment).

So first off go and download any version of Visual Studio(the environment i will get you to use). This should be free off many sites.  I am using Visual Studio C++ 2008 express edition if any cares. Now once everything is installed and what not. You should run the program and come to a nice menu. Mine looks like...


Okay from here go to :

1. File/New/Project.
 
2. There will be a column project types. Click on Win32.
     Now in the Templates section. Click on Win32 Console Application.
     Now name your project anything. Lets say "First Program" .

3. It will now ask you questions. Click Next. On this screen make sure the bubble. Application type is
clicked  on Console Application. Also make sure that you click Empty project. The click Finish.

4. You should now be brought to the original menu. But now in your recent projects shows your project name. Now glance to the far right of the menu. There should be a folder named Source Files. Right click this and add new item. Under the categories select Code. In the templates body select the file that has an extension .cp or .cpp. Should be named C file or C++ file.

5. Name this file. I usually just name it the name of my project in most cases. If everything went right you should be looking at a screen similiar to this.

 6. Now to start coding. In that blank white area is where you type your code. So time to write are first program.

# include <stdio.h>

void main()
{
      printf("Hello World\n");
}

There's your first program.

7. Now it's time to build it and run it. At the top there should be a menu build. Click this and build solution. At the bottom will have a bunch of crazy writing appear and then will tell you if the build succeeded. The above code should be error free so it will say succeeded: 1 or something along those lines.

8. Now to run it go to Debug next to build. Then click start without debugging. Enjoy you now have just created a program.


Any questions or you get lost comment.

25 comments:

  1. This will help me impress all the chicks in computer class ^_~

    ReplyDelete
  2. I wish I had time to learn some programming.

    Supported.
    bigunicorn.blogspot.com

    ReplyDelete
  3. Interesting post! I want to learn C eventually. Now doing ActionScript. lol

    Followed!

    ReplyDelete
  4. I prefer to program via Unix, but meh.

    ReplyDelete
  5. I just started a computer science degree and the first language we learn is Java.

    ReplyDelete
  6. I would like to eventually learn this stuff but I'm afraid I'm a little slow with this. Interesting blog, though. Following.

    ReplyDelete
  7. I'm learning Python atm. Don't laugh at me. I'm going into C slowly.....

    ReplyDelete
  8. Oh cool! This is definitely worth bookmarking for future reference. I wish I had the time to put into learning some programming at the moment.

    ReplyDelete
  9. I learned c programming in school :)
    Followed :D

    ReplyDelete
  10. Also a computer science major. Very accurate and straightforward. Microsoft products are so unintuitive :S

    ReplyDelete
  11. I couldn't believe my C++ teacher didn't start with Hello World. There should be a law about that, or something.

    ReplyDelete
  12. I am always wanting to learn more. Keep up the good posts.

    ReplyDelete
  13. Brilliant guide... I'm so noob at this!

    ReplyDelete
  14. Ahh too complicated for me! thanks for sharing the tutorial though! keep up the great work!

    ReplyDelete
  15. we did some java in school, but didn't like that a lot :( might try to learn C++ now tho

    nice blog! following :)

    ReplyDelete
  16. Gotta try this. Good stuff here, follow´d

    ReplyDelete
  17. Awesome, always wanted to learn how to program.

    ReplyDelete
  18. Nice I don't have much experience with this but this is definitely very useful information for the future.

    ReplyDelete
  19. Always wanted to try out C language but it seems too complex. Only have done some Visual Basic programs.

    ReplyDelete
  20. I C I C. I made this program before :D

    ReplyDelete
  21. I only wish i could understand these things :(

    ReplyDelete
  22. Lost before I even got started x_X No talent for programming aha d;

    ReplyDelete
  23. this is good blog. programming is easy actually

    ReplyDelete