Thread: Look at my crappy program. Look at it!

  1. #16
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Hirumaru View Post
    Oh, and a question. This is the basic purpose for creating a function, more or less, right?
    We have functions for many reasons. If some chunk of code performs a well-defined task, placing it in a function can lead to clearer code. It allows us to reuse the code, if the same thing has to happen in more than one place. It allows us to provide a pointer to the function, which lets other code invoke our code even though it doesn't know anything about it. It also enables recursion, which would not be possible otherwise.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  2. #17
    Registered User
    Join Date
    Mar 2009
    Posts
    7
    That's kinda what I meant. You can't keep going back to main() for everything. Especially not so when your program has hundreds of lines of code and performs dozens of distinct operations.

    You need to be able to find, use, and reuse code efficiently. Otherwise your program'll get bottlenecked asking the same code for twenty different operations all at once.

    Heh. Programming is going to be so much fun. ^_^

    -Hiru

  3. #18
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Hirumaru View Post
    That's kinda what I meant. You can't keep going back to main() for everything. Especially not so when your program has hundreds of lines of code and performs dozens of distinct operations.
    You've grasped the point I think.

    Now, wait until you look at a multi-million line program I used to work on a codebase of 1.4 million lines. Now I only have to deal with 65 thousand lines, which seems small in comparison.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #19
    Registered User
    Join Date
    Mar 2009
    Posts
    7
    Quote Originally Posted by brewbuck View Post
    Now, wait until you look at a multi-million line program .
    Just as long as I don't get eaten by an over-sized chicken like Dennis Nedry. @_@

    -Hiru

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM