C Tutorial (1 - First Program) - Page 2
Register

We are the best invite forum on the internet! Here you will find free invites, free seedboxes, free bonuses, and much more. Our members know the true meaning of sharing and have created a truly global bittorent community! Our site has the most up to date information on all private trackers and our members will guide you and introduce you to this truly secretive and enlightened club. Ready to get started? Register now!


Page 2 of 2 FirstFirst 1 2
Results 11 to 20 of 20
Like Tree1Likes

Thread: C Tutorial (1 - First Program)

  1. #11

    Join Date
    Feb 2011
    Location
    Delhi, New York, United States
    Posts
    43

    Default

    I'm going to try those tips. I wrote the program in gedit and compiled it with gcc via command line and when I ran it, it didn't 'end' correctly.

    but I was proud of it non the less :)



  2. To remove ads become VIP. Inquire about advertising here.
  3. #12

    Join Date
    Feb 2011
    Posts
    86

    Default

    hmm. Perhaps you forgot to return 0 at the end? Normally not ending correctly means it returned other than 0, i.e. error.

  4. #13

    Join Date
    Nov 2010
    Posts
    19

    Default

    @Sever, actually I just looked at the program again, the system("pause") command will not work in Linux. And even in Windows, it's probably best to avoid it, since it is heavy on resources and not portable to other operating systems.

    There's a variety of things you can use instead. For this program, since you are running it from the command line, you can just delete that whole line, since it doesn't really do anything important. So for the first program you can write this:

    #include <stdio.h>

    int main()
    {

    printf("Hello World\n");

    return 0;

    }

    If you do want your system to pause, here is an alternative you can use:
    Things to Avoid in C/C++ -- system("pause"), Part 4 - GIDNetwork

    By the way, since you are now using return 0, in Linux to check how your last command executed type

    echo $?

    This will show you the return value of the last executed command. By default, the return value of 0 means the command executed correctly. When you start writing bigger programs, you can define your own return values for various errors, and then you will know what caused the error.

  5. #14

    Join Date
    Jul 2009
    Location
    CA
    Posts
    274

    Default

    Afaik, there is no "pause" command in linux. You can use getchar() instead, it should work for both windows and linux.

  6. #15

    Join Date
    Jul 2010
    Posts
    107

    Default

    I decided to learn this language. I found some good example programming tasks for beginners on a school's website. Unfortunately I can't get along with them, though I heard that they are really easy. If anyone has some time to help me by writing some code with detailed comments /so I would have a better view about functions and what do they do/ please pm me. I woul really appreciate that. :)

  7. #16

    Join Date
    Mar 2011
    Posts
    75

    Default

    I agree with what you said about using int main() but better still to write int main(void) if you're not using command line args I think, or else specify them.

  8. #17

    Join Date
    Apr 2011
    Location
    Washington
    Posts
    23

    Default Re: C Tutorial (1 - First Program)

    I started learning C in computer architecture. I had no experience with C prior to that class and our first program was like this. Our final program was to create an LC-3 assembler. I still have nightmares from that class. Can't wait to see some of your advanced tutorials.

  9. #18

    Join Date
    Feb 2011
    Location
    Delhi, New York, United States
    Posts
    43

    Default Re: C Tutorial (1 - First Program)

    are there more tutorials on this subject, c++? I would be greatly interested. Me and a buddy of mine. It seems to have stopped at tutorial one

  10. #19

    Join Date
    May 2011
    Posts
    5

    Default Re: C Tutorial (1 - First Program)

    Quote Originally Posted by Sever View Post
    are there more tutorials on this subject, c++? I would be greatly interested. Me and a buddy of mine. It seems to have stopped at tutorial one
    i think it hasn't any sense to create new tutorials when you can read it all using google ;) c++ is very popular programming language so you can find more than you need :)

  11. #20

    Join Date
    Dec 2010
    Location
    Candlekeep
    Posts
    483

    Default Re: C Tutorial (1 - First Program)

    Yay, the good old Hello world at its best :)

    I love the style of this tutorial, as it goes very much into detail and is great for beginners to get a grip on the concept of programming in general.

    I think C is a good language to start with as its basics are relatively easy to learn but later on the language can be used for very complex programstructures aswell.
    So you picked a good way to visualize this topic and I enjoyed reading it although I know this program in and out already by now :D

    Good Work!

    zealot
    Thanks to oki and UBi for repping me in!

    Please visit my 10% GiveAway!

Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. Replies: 12
    Last Post: February 9th, 2012, 07:44 AM
  2. PHP Programming with MySQL Beginner's Tutorial
    By Brenden in forum Internet
    Replies: 0
    Last Post: January 17th, 2011, 01:53 PM
  3. First program/site used for download?
    By twix0r4564 in forum BitTorrent Discussion
    Replies: 26
    Last Post: November 25th, 2009, 09:29 PM
  4. what was the first thing u leeched ?
    By snake in forum General Discussion
    Replies: 92
    Last Post: October 19th, 2009, 07:15 AM
  5. Replies: 0
    Last Post: May 19th, 2008, 01:52 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •