Thread: Defining functions outside main - problem

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    i was told by my supervisor that i was meant to write f1 as a function of i when it was in the loop!
    I see. What does f1() do, and why on earth do you name it f1 when you can use a more descriptive name?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Registered User
    Join Date
    Mar 2006
    Posts
    9
    ok, ill change it! it is a function that is defined outside of int main. it has to compute values of a function at each iteration step in a loop statement. hence it is dependent on i! i have defined it at the top outside main, and then put the formula at the bottom after my return(0) }. the problem is that im not sure how to make it use the formula for each iteration step, also i have arrays in there, so it complicates it even further and puts it outside of my knowledge!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program skips functions in main
    By En-Motion in forum C++ Programming
    Replies: 5
    Last Post: 02-18-2009, 09:35 PM
  2. Problem with functions
    By WTFSEAN in forum C Programming
    Replies: 5
    Last Post: 05-10-2008, 02:01 AM
  3. Problem: Functions
    By Dmitri in forum C Programming
    Replies: 21
    Last Post: 11-06-2005, 10:40 AM
  4. Static variables and functions problem in a class
    By earth_angel in forum C++ Programming
    Replies: 16
    Last Post: 09-15-2005, 12:08 PM
  5. Big Problem With Passing an Matrix to Main Function
    By Maragato in forum C Programming
    Replies: 4
    Last Post: 06-14-2004, 11:06 PM