function call

This is a discussion on function call within the C++ Programming forums, part of the General Programming Boards category; Hello all! I'm trying to write a program that reads in length in feet and inches, and outputs the equivalent ...

  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
    Attached Files Attached Files

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    For one, you should be passing your variables (feet, inches, etc.) by reference, not value.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  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, 04: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-17-2006, 12:35 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM

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