Click here to Skip to main content
16,005,120 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Heap problem?? desperately need help. Pin
alberthyc1-Aug-07 11:05
alberthyc1-Aug-07 11:05 
GeneralRe: Heap problem?? desperately need help. Pin
Mark Salsbery1-Aug-07 11:23
Mark Salsbery1-Aug-07 11:23 
GeneralRe: Heap problem?? desperately need help. Pin
alberthyc1-Aug-07 11:32
alberthyc1-Aug-07 11:32 
GeneralRe: Heap problem?? desperately need help. Pin
Mark Salsbery1-Aug-07 11:37
Mark Salsbery1-Aug-07 11:37 
GeneralRe: Heap problem?? desperately need help. Pin
alberthyc1-Aug-07 11:46
alberthyc1-Aug-07 11:46 
GeneralRe: Heap problem?? desperately need help. Pin
Mark Salsbery1-Aug-07 11:58
Mark Salsbery1-Aug-07 11:58 
GeneralRe: Heap problem?? desperately need help. Pin
Mark Salsbery1-Aug-07 12:08
Mark Salsbery1-Aug-07 12:08 
QuestionDebugging Error Pin
pheven1-Aug-07 8:50
pheven1-Aug-07 8:50 
Hello everyone, just wanted to say that this is my first post ever, so here goes...

I have sucessfully created and compiled a program that is supposed to calculate your age in either dog or cat years (based on your choice). Unfortunately, whenever I try and execute or debug it, nothing happens. On debugg, the command window flashes for a second and then is gone, and when running it from the command line, nothing happens at all.

I am just staring out with programming, but I think that my functions are not being called properly somehow, perhaps in the main module? I have attached the code at the bottom here, and any help given will be greatly appreciated. Thanks.



//************************//
//Animal Age Calculator //
//Phelan Vendeville //
//31 JUL 2007 //
//************************//

#include <iostream>

float age_module(float human_age); //function prototype
float animal_module(float dogyears, float catyears); //second function prototype

int main()
{
using namespace std ;

float age_module(float human_age); //call to function

float animal_module(float dogyears, float catyears); //call to second function
}

float age_module (float human_age) //custom function itself
{
using namespace std ;

cout << endl ;
cout << "Please enter your age (integer please)";
cin >> human_age ;

if (human_age <= 0)
{
cout << endl;
cout << "Please enter your real age (integer)";
cin >> human_age;
return (human_age);
}
else
{
(human_age > 0);
cout << "Your human age is: " << human_age <<endl;
return (human_age);
}

}

float dogfunction (float human_age, float dogyears); //subfunction prototypes
float catfunction (float human_age, float catyears);

float animal_module(float dogyears, float catyears) //second custom function (itself)
{
using namespace std ;
char type;
cout << endl ;
cout << "Would you like your age in Dog or Cat years? (D for Dog, C for Cat, capitalized)";
cin >> type ;

if (type == 'D')
{
float dogfunction (float human_age, float dogyears);//call to function
cout << endl;
cout << "Your age in dog years is:" <<dogyears <<endl;
return dogyears;
}

else if (type == 'C')
{
float catfunction (float human_age, float catyears);//call to function
cout << endl;
cout << "your age in cat years is:" <<catyears << endl;
return catyears;
}
else
{
cout <<endl ;
cout << "Please enter your choice, D or C" <<endl;
return 0;
}
}

float dogfunction (float human_age, float dogyears)
{
using namespace std;

if (human_age <= 2)
{
dogyears = human_age * 10.5f; //the reason that the f is there is to tell the comiler that the 10.5 is a float, not a double, which it thinks it is by default.
return (dogyears);
}

else
{
dogyears = (human_age * 4) - 21;
return (dogyears);
}
}

float catfunction (float human_age, float catyears)
{
using namespace std;

if (human_age == 1)
{
catyears = 15;
return (catyears);
}
else if (human_age == 2)
{
catyears = 24;
return (catyears);
}
else
{
catyears = (human_age * 4) - 24;
return (catyears);
}
}
AnswerRe: Debugging Error Pin
Michael Dunn1-Aug-07 9:31
sitebuilderMichael Dunn1-Aug-07 9:31 
AnswerRe: Debugging Error Pin
Mark Salsbery1-Aug-07 9:40
Mark Salsbery1-Aug-07 9:40 
GeneralRe: Debugging Error Pin
pheven1-Aug-07 10:50
pheven1-Aug-07 10:50 
QuestionTTS SAPI5 Pin
pablov061-Aug-07 8:14
pablov061-Aug-07 8:14 
QuestionAccess Report DB Pin
mk_le1-Aug-07 8:13
mk_le1-Aug-07 8:13 
QuestionHow to copy a file opened by other process with forbidden sharing? Pin
Vlad01-Aug-07 7:48
Vlad01-Aug-07 7:48 
AnswerRe: How to copy a file opened by other process with forbidden sharing? Pin
JudyL_MD1-Aug-07 9:38
JudyL_MD1-Aug-07 9:38 
AnswerRe: How to copy a file opened by other process with forbidden sharing? Pin
Randor 1-Aug-07 10:01
professional Randor 1-Aug-07 10:01 
GeneralRe: How to copy a file opened by other process with forbidden sharing? Pin
Vlad02-Aug-07 8:29
Vlad02-Aug-07 8:29 
GeneralRe: How to copy a file opened by other process with forbidden sharing? [modified] Pin
Vlad022-Aug-07 7:54
Vlad022-Aug-07 7:54 
AnswerRe: How to copy a file opened by other process with forbidden sharing? Pin
Peter Weyzen1-Aug-07 21:16
Peter Weyzen1-Aug-07 21:16 
GeneralRe: How to copy a file opened by other process with forbidden sharing? Pin
Vlad02-Aug-07 5:14
Vlad02-Aug-07 5:14 
Questionbetter way for executing system commands [modified] Pin
koumodaki1-Aug-07 6:30
koumodaki1-Aug-07 6:30 
AnswerRe: better way for executing system commands Pin
_AnsHUMAN_ 1-Aug-07 7:12
_AnsHUMAN_ 1-Aug-07 7:12 
AnswerRe: better way for executing system commands Pin
James R. Twine1-Aug-07 7:23
James R. Twine1-Aug-07 7:23 
AnswerRe: better way for executing system commands Pin
David Crow1-Aug-07 7:27
David Crow1-Aug-07 7:27 
QuestionUtilizing resource files Pin
Torus_XL1-Aug-07 5:50
Torus_XL1-Aug-07 5:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.