Thread: function call

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    3

    Question function call

    Hello all!

    I'm trying to write a program that reads in length in feet and inches, and outputs the equivalent meters and centimeters using at least 3 functions (input, calculate and output). The program includes a loop that allows the user to calculate as often as they'd like. The program runs, but doesn't calculate correctly. I know at a minimun my function call is wrong, but I don't know how to fix it. Any suggestions?

    Thanx

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    For one, you should be passing your variables (feet, inches, etc.) by reference, not value.
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    i have to head out so heres a very quick reply, and maybe i can get back to it another time:

    - please post your code using code tags, making us download and look at the file is another step for us (who are already offering help for free)

    - your "input" function must take those 2 parameters by reference, look this up and learn it if you havent heard it before, or simply put the logic in this function into main (instead of creating a function for it, which doesnt really help)

    - if you follow the logic of your code, the "equiv_m" function will accept 2 arguments, the first of which, "feet", is being used without being initialized (resulting in "undefined" behaviour)

    - in this same function, the last line wont ever be executed because the second last line is a return statement (so the function "exits" after the return)

    i havent read the rest but i imagine you can start from there.

  4. #4
    Registered User
    Join Date
    Sep 2009
    Posts
    3
    You're right. Thanks!

  5. #5
    Registered User
    Join Date
    Sep 2009
    Posts
    3
    I apologize for not sending the tags; I uploaded the wrong file. Thanks for all your help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM