Thread: RE: [Dev-C++] problem calling functions
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: James G. <Jam...@Cl...> - 2001-01-16 13:39:42
|
Your function calls don't have () on the end. Even if you do not pass parameters to functions you must include empty () when calling the functions. The deceleration of inpu doesn't pass parameters but the definition requires an int. Regards, James. -----Original Message----- From: jag [mailto:won...@th...] Sent: Tuesday, January 16, 2001 11:33 AM To: devc++ mail-list Subject: [Dev-C++] problem calling functions ----------------------------------------------------- This email was delivered to you by the Free Internet, a Business Online Group company. Join TFI at http://www.thefreeinternet.net - the UK's premier 0800, free access ISP. ----------------------------------------------------- Hi, can anyone tell me where i'm going wrong with my coding? The code is at the end of the email. It's a simple program to practice function calls. I want to enter either a number 1 or number 2 to call seperate functions. When the functions are called it prints a simple message to say that the function has been successfully called, i can n't get the program to call the functions however! Can anyone advise me why? thanks in advance jag. #include <stdio.h> #include <iostream.h> int again; int enteb; void outpu(void); void inpu(void); int main(int argc, char *argv[]) { cout <<"monkey type (1) for function outpu (1) or (2) for function inpu"; cin >>enteb; if (enteb == 1) { outpu; } if (enteb == 2) { inpu; } cout <<"neither 1 or 2\n"; cout <<"wait for a number and enter pressed"; cin >> again; return 0; } void outpu(void) { cout <<"calling function outpu "<<enteb; } void inpu(int enteb) { cout <<"calling function inpu "<<enteb; } ICQ #103968172 _______________________________________________ Dev-cpp-users mailing list Dev...@li... http://lists.sourceforge.net/lists/listinfo/dev-cpp-users * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This electronic message and any attachment is intended to be read by the named addressee(s) only. Any other recipient should be aware that its contents may be legally privileged and/or confidential and that its use, disclosure, copying or distribution may be unlawful. Unless you are a named addressee, please delete this message Whilst C. & J. Clark International Limited has taken steps to prevent the transmission of computer viruses with electronic mail, responsibility for screening incoming messages and the risk of such transmission and its consequences lies with the recipient. C. & J. Clark International Limited Registered in England and Wales Company No. 141015 Registered Office: 40 High Street, Street, Somerset BA16 0YA Telephone: +44 (0) 1458 443131 Fax: +44 (0) 1458 447547 |
|
From: tayo o. <ta...@ya...> - 2001-01-17 02:22:50
|
Please can some one help me: Who knows an excellent text book for Data structures via C++, or a good web site that i can use to learn data structures via C++. Thanks. tayo odesanya. --- Ioannis Vranos <no...@ya...> wrote: > > -----Original Message----- > > From: dev...@li... > > > [mailto:dev...@li...]On > Behalf Of jag > > Sent: Tuesday, January 16, 2001 1:33 PM > > To: devc++ mail-list > > Subject: [Dev-C++] problem calling functions > > > > > > > ----------------------------------------------------- > > This email was delivered to you by the Free > Internet, > > a Business Online Group company. > > > > Join TFI at http://www.thefreeinternet.net - > > the UK's premier 0800, free access ISP. > > > ----------------------------------------------------- > > > > Hi, can anyone tell me where i'm going wrong with > my coding? The > > code is at > > the end of the email. It's a simple program to > practice function > > calls. I > > want to enter either a number 1 or number 2 to > call seperate functions. > > When the functions are called it prints a simple > message to say that the > > function has been successfully called, i can n't > get the program > > to call the > > functions however! Can anyone advise me why? > > > > thanks in advance > > jag. > > > > #include <stdio.h> > > #include <iostream.h> > > Bad attitude. :) Try to stick with C or C++ higher > level constructs only. > > > > int again; > > int enteb; > > void outpu(void); > > void inpu(void); > > > > int main(int argc, char *argv[]) > > > > { > > cout <<"monkey type (1) for function outpu (1) or > (2) for function inpu"; > > > > cin >>enteb; > > if (enteb == 1) > > { > > > > outpu; > > It should be outpu(); > > > } > > > > if (enteb == 2) > > { > > inpu; > > inpu(); > > > } > > cout <<"neither 1 or 2\n"; > > cout <<"wait for a number and enter pressed"; > > cin >> again; > > > > return 0; > > } > > void outpu(void) > > { > > > > cout <<"calling function outpu "<<enteb; > > > > } > > void inpu(int enteb) > > { > > > > > > cout <<"calling function inpu "<<enteb; > > > > } > > ICQ #103968172 > > > > > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ |
|
From: Alan T. <ala...@3n...> - 2001-01-17 02:29:03
|
Jag,
I think you need "()" when you call your function, even if the
parameter is a void. Better yet, why don`t you pass your variables to your
functions? It is best to avoid global variables whenever possible.
Better naming of things (functions, variables, etc.) would make your
program more readable. There are also better styles for checking the
validity of input. For example, how about the following rewrite of your
program....
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>
void function_1 (int int_in);
void function_2 (int int_in);
int main(int argc, char *argv[])
{
int input;
int Validated_Input = false;
while (!(Validated_Input))
{
cout <<"monkey type (1) for function 1 or (2) for function 2: ";
cin >> input;
if ((input == 1) || (input == 2))
Validated_Input = true;
else
{
Validated_Input = false;
cout << endl << " Invalid entry. Try again." << endl;
}
}
if (input == 1)
function_1(input);
else if (input == 2)
function_2(input);
system("PAUSE");
return 0;
}
void function_1 (int int_in)
{
cout <<"calling function "<<int_in << endl;
}
void function_2 (int int_in)
{
cout <<"calling function "<<int_in << endl;
}
> From: "jag" <won...@th...>
> Date: Tue, 16 Jan 2001 11:32:47 -0000
> Subject: [Dev-C++] problem calling functions
>
> Hi, can anyone tell me where i'm going wrong with my coding? The code is
at
> the end of the email. It's a simple program to practice function calls.
I
> want to enter either a number 1 or number 2 to call seperate functions.
> When the functions are called it prints a simple message to say that the
> function has been successfully called, i can n't get the program to call
the
> functions however! Can anyone advise me why?
>
> thanks in advance
> jag.
|
|
From: sushmita u. <sus...@ya...> - 2001-01-17 05:05:18
|
data structure through c++ by tanenbaum. --- tayo odesanya <ta...@ya...> wrote: > Please can some one help me: Who knows an > excellent > text book for Data structures via C++, or a good > web > site that i can use to learn data structures via > C++. > Thanks. > tayo odesanya. > > > > > > > --- Ioannis Vranos <no...@ya...> wrote: > > > -----Original Message----- > > > From: dev...@li... > > > > > > [mailto:dev...@li...]On > > Behalf Of jag > > > Sent: Tuesday, January 16, 2001 1:33 PM > > > To: devc++ mail-list > > > Subject: [Dev-C++] problem calling functions > > > > > > > > > > > > ----------------------------------------------------- > > > This email was delivered to you by the Free > > Internet, > > > a Business Online Group company. > > > > > > Join TFI at http://www.thefreeinternet.net - > > > the UK's premier 0800, free access ISP. > > > > > > ----------------------------------------------------- > > > > > > Hi, can anyone tell me where i'm going wrong > with > > my coding? The > > > code is at > > > the end of the email. It's a simple program to > > practice function > > > calls. I > > > want to enter either a number 1 or number 2 to > > call seperate functions. > > > When the functions are called it prints a simple > > message to say that the > > > function has been successfully called, i can n't > > get the program > > > to call the > > > functions however! Can anyone advise me why? > > > > > > thanks in advance > > > jag. > > > > > > #include <stdio.h> > > > #include <iostream.h> > > > > Bad attitude. :) Try to stick with C or C++ higher > > level constructs only. > > > > > > > int again; > > > int enteb; > > > void outpu(void); > > > void inpu(void); > > > > > > int main(int argc, char *argv[]) > > > > > > { > > > cout <<"monkey type (1) for function outpu (1) > or > > (2) for function inpu"; > > > > > > cin >>enteb; > > > if (enteb == 1) > > > { > > > > > > outpu; > > > > It should be outpu(); > > > > > } > > > > > > if (enteb == 2) > > > { > > > inpu; > > > > inpu(); > > > > > } > > > cout <<"neither 1 or 2\n"; > > > cout <<"wait for a number and enter pressed"; > > > cin >> again; > > > > > > return 0; > > > } > > > void outpu(void) > > > { > > > > > > cout <<"calling function outpu "<<enteb; > > > > > > } > > > void inpu(int enteb) > > > { > > > > > > > > > cout <<"calling function inpu "<<enteb; > > > > > > } > > > ICQ #103968172 > > > > > > > > > _______________________________________________ > > > Dev-cpp-users mailing list > > > Dev...@li... > > > > > > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > __________________________________________________ > Do You Yahoo!? > Get email at your own domain with Yahoo! Mail. > http://personal.mail.yahoo.com/ > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ |
|
From: sushmita u. <sus...@ya...> - 2001-01-17 06:05:46
|
thank u for the instructions.I will always remember it but i don't remember whthr i have ever psted such problem to u .any way thanks --- James Gordon <Jam...@Cl...> wrote: > Your function calls don't have () on the end. > Even if you do not pass parameters to functions you > must include empty () > when calling the functions. > > The deceleration of inpu doesn't pass parameters but > the definition requires > an int. > > Regards, > > James. > > > -----Original Message----- > From: jag [mailto:won...@th...] > Sent: Tuesday, January 16, 2001 11:33 AM > To: devc++ mail-list > Subject: [Dev-C++] problem calling functions > > > ----------------------------------------------------- > This email was delivered to you by the Free > Internet, > a Business Online Group company. > > Join TFI at http://www.thefreeinternet.net - > the UK's premier 0800, free access ISP. > ----------------------------------------------------- > > Hi, can anyone tell me where i'm going wrong with my > coding? The code is at > the end of the email. It's a simple program to > practice function calls. I > want to enter either a number 1 or number 2 to call > seperate functions. > When the functions are called it prints a simple > message to say that the > function has been successfully called, i can n't get > the program to call the > functions however! Can anyone advise me why? > > thanks in advance > jag. > > #include <stdio.h> > #include <iostream.h> > int again; > int enteb; > void outpu(void); > void inpu(void); > > int main(int argc, char *argv[]) > > { > cout <<"monkey type (1) for function outpu (1) or > (2) for function inpu"; > > cin >>enteb; > if (enteb == 1) > { > > outpu; > } > > if (enteb == 2) > { > inpu; > } > cout <<"neither 1 or 2\n"; > cout <<"wait for a number and enter pressed"; > cin >> again; > > return 0; > } > void outpu(void) > { > > cout <<"calling function outpu "<<enteb; > > } > void inpu(int enteb) > { > > > cout <<"calling function inpu "<<enteb; > > } > ICQ #103968172 > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * * * * * * > This electronic message and any attachment is > intended to be > read by the named addressee(s) only. > Any other recipient should be aware that its > contents may be > legally privileged and/or confidential and that its > use, > disclosure, copying or distribution may be unlawful. > > Unless you are a named addressee, please delete this > message > > Whilst C. & J. Clark International Limited has taken > steps > to prevent the transmission of computer viruses with > electronic mail, > responsibility for screening incoming messages and > the risk of such > transmission and its consequences lies with the > recipient. > > C. & J. Clark International Limited > Registered in England and Wales > Company No. 141015 > Registered Office: 40 High Street, Street, Somerset > BA16 0YA > Telephone: +44 (0) 1458 443131 > Fax: +44 (0) 1458 447547 > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ |
|
From: James G. <Jam...@Cl...> - 2001-01-17 12:07:25
|
You didn't post to me, you posted to the Dev-C++ list, of which I am a member. Regards, James. -----Original Message----- From: sushmita upadhaya [mailto:sus...@ya...] Sent: Wednesday, January 17, 2001 6:06 AM To: dev...@li... Subject: RE: [Dev-C++] problem calling functions thank u for the instructions.I will always remember it but i don't remember whthr i have ever psted such problem to u .any way thanks --- James Gordon <Jam...@Cl...> wrote: > Your function calls don't have () on the end. > Even if you do not pass parameters to functions you > must include empty () > when calling the functions. > > The deceleration of inpu doesn't pass parameters but > the definition requires > an int. > > Regards, > > James. > > > -----Original Message----- > From: jag [mailto:won...@th...] > Sent: Tuesday, January 16, 2001 11:33 AM > To: devc++ mail-list > Subject: [Dev-C++] problem calling functions > > > ----------------------------------------------------- > This email was delivered to you by the Free > Internet, > a Business Online Group company. > > Join TFI at http://www.thefreeinternet.net - > the UK's premier 0800, free access ISP. > ----------------------------------------------------- > > Hi, can anyone tell me where i'm going wrong with my > coding? The code is at > the end of the email. It's a simple program to > practice function calls. I > want to enter either a number 1 or number 2 to call > seperate functions. > When the functions are called it prints a simple > message to say that the > function has been successfully called, i can n't get > the program to call the > functions however! Can anyone advise me why? > > thanks in advance > jag. > > #include <stdio.h> > #include <iostream.h> > int again; > int enteb; > void outpu(void); > void inpu(void); > > int main(int argc, char *argv[]) > > { > cout <<"monkey type (1) for function outpu (1) or > (2) for function inpu"; > > cin >>enteb; > if (enteb == 1) > { > > outpu; > } > > if (enteb == 2) > { > inpu; > } > cout <<"neither 1 or 2\n"; > cout <<"wait for a number and enter pressed"; > cin >> again; > > return 0; > } > void outpu(void) > { > > cout <<"calling function outpu "<<enteb; > > } > void inpu(int enteb) > { > > > cout <<"calling function inpu "<<enteb; > > } > ICQ #103968172 > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * * * * * * > This electronic message and any attachment is > intended to be > read by the named addressee(s) only. > Any other recipient should be aware that its > contents may be > legally privileged and/or confidential and that its > use, > disclosure, copying or distribution may be unlawful. > > Unless you are a named addressee, please delete this > message > > Whilst C. & J. Clark International Limited has taken > steps > to prevent the transmission of computer viruses with > electronic mail, > responsibility for screening incoming messages and > the risk of such > transmission and its consequences lies with the > recipient. > > C. & J. Clark International Limited > Registered in England and Wales > Company No. 141015 > Registered Office: 40 High Street, Street, Somerset > BA16 0YA > Telephone: +44 (0) 1458 443131 > Fax: +44 (0) 1458 447547 > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ _______________________________________________ Dev-cpp-users mailing list Dev...@li... http://lists.sourceforge.net/lists/listinfo/dev-cpp-users * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This electronic message and any attachment is intended to be read by the named addressee(s) only. Any other recipient should be aware that its contents may be legally privileged and/or confidential and that its use, disclosure, copying or distribution may be unlawful. Unless you are a named addressee, please delete this message Whilst C. & J. Clark International Limited has taken steps to prevent the transmission of computer viruses with electronic mail, responsibility for screening incoming messages and the risk of such transmission and its consequences lies with the recipient. C. & J. Clark International Limited Registered in England and Wales Company No. 141015 Registered Office: 40 High Street, Street, Somerset BA16 0YA Telephone: +44 (0) 1458 443131 Fax: +44 (0) 1458 447547 |