Newbie questions

This is a discussion on Newbie questions within the C Programming forums, part of the General Programming Boards category; I have a few amateur questions if you don't mind answering: 1. Why are functions defined completely after the main ...

  1. #1
    Registered User Black_Epiphany's Avatar
    Join Date
    Sep 2011
    Posts
    15

    Newbie questions

    I have a few amateur questions if you don't mind answering:

    1. Why are functions defined completely after the main function? (what is the purpose of the prototype?)

    2. Are there any good sites where I can view sample source code from simple games and program that you reccommend? (besides the ones on this site?)

    Thanks for taking the time to help me out!

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    1) Functions don't have to be defined after main... you can do it above main. What you can't do is call a function before the compiler sees it. The compiler reads a page top-down so if you call a function it hasn't seen yet it's going to make some assumptions about it and then it will error off if the asusmptions prove to be incorrect (which they almost always are). This is where prototypes come in... the prototype above main is telling the compiler there is a full function you call just like that somewhere further on in the source code...

    2) Yep, the best site is the one thing I think you most need to be using... Get a good textbook on C ... start on page 1, read every word, compile the examples and do the exercises, play with the code until you understand it... then turn to page 2 and repeat... When you get to the end of the book you will be in a position to write small, usually console mode, programs... and then the rest is good documentation, practice and experience.


    No offense, but the way you're going about this is NOT how you learn C programming.

  3. #3
    Registered User Black_Epiphany's Avatar
    Join Date
    Sep 2011
    Posts
    15
    Lol thanks CommonTater.

    What books do you recommend?

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    See that link at the top of the main page?

    C Book Recommendations

    Read.


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User Black_Epiphany's Avatar
    Join Date
    Sep 2011
    Posts
    15
    Didn't notice. Reading now. :-D

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Black_Epiphany View Post
    Didn't notice. Reading now. :-D
    Teach Yourself C in 21 Days is pretty good (that's what I started with)

    The C Programming Language (Kernahan and Ritchie) is very well liked.

    Both are available on Amazon...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. More newbie questions
    By sunzoner in forum C++ Programming
    Replies: 3
    Last Post: 06-11-2002, 06:23 AM
  2. Some newbie questions
    By monkeymon in forum C++ Programming
    Replies: 12
    Last Post: 06-08-2002, 09:35 PM
  3. 2 questions, (newbie needs help)
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 09-21-2001, 12:19 AM
  4. newbie questions again
    By dune911 in forum C++ Programming
    Replies: 2
    Last Post: 09-14-2001, 02:43 PM
  5. c++ newbie questions
    By dune911 in forum C++ Programming
    Replies: 2
    Last Post: 09-14-2001, 06:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21