dev-cpp-users Mailing List for Dev-C++ (Page 524)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
| 2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
| 2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
| 2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
| 2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
| 2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
| 2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
| 2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
| 2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
| 2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
| 2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
| 2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
| 2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
| 2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
| 2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
| 2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Abhijit S. <mu...@gm...> - 2002-09-18 16:41:49
|
Greets.
> Hello everybody,
>
> I tried to write a programm which does execute some dos command (like
tracert, ping etc.) with an ip.
>
> At first, I created a string (#include <string>), but when I tried to
execute it with the system()-command, I got the following error
(exec=string-Variable):
> "cannot convert 'exec' from type string to type 'const char*'"
>
> Finally -after some hours of trying :)- I've got the following solution:
>
> #include <iostream>
> #include <stdlib.h>
>
>
> int main()
> {
> int i;
> char pcno[20];
>
> cout << "Enter the ip to trace:" , cin >> pcno; //enter domain-name of pc
(domain-name is supposed to be 8 chars long)
>
> for (i=0;i<8;i++){pcno[i+8]=pcno[i];}; //put the domain name at the end
> pcno[0]='t';
> pcno[1]='r';
> pcno[2]='a';
> pcno[3]='c'; //enter the dos-command in the
first chars
> pcno[4]='e';
> pcno[5]='r';
> pcno[6]='t';
> pcno[7]=' ';
> for (i=16;i<40;i++){pcno[i]=' ';};
>
> system(pcno);
> system("PAUSE");
> return 0;
> }
>
>
> Does someone know an easier solution?
Try this (untested and unparsed, minor changes maybe necessary :)
string whatever = "foo";
system(foo.c_str());
___________________________________________________________
Abhijit Shylanath
E-mail: mu...@gm... || ibr...@bi...
Web-site: http://mudeth.tripod.com/
|
|
From: Stringer, A. <Adr...@as...> - 2002-09-18 15:19:26
|
--- #include "stdio.h" #include "string.h" #include "stdlib.h" --- I may be wrong here, and if so feel free to slap me, but I think that ought to be #include <cstdio> #include <cstring> #include <cstdlib> and your own header files should be included as #include "myheader.h" See the end of http://www.comeaucomputing.com/techtalk/#cname. I quote: --> Similarly, the Standard C headers, such as <stdio.h>, are supported in C++, but they are deprecated. Instead, so-called Cname headers are preferred, for instance, cstdio, or cctype instead of ctype.h Furthermore, names in the .h are assumed to be in the global namespace, and so therefore do not need to be qualified with std::. The .h form is sometimes used as a transition model for backwards compatibility. Or, for a "co-ed" source file able to be compiled by a C or C++ compiler. <-- Sorry to be pedantic, Adrian |
|
From: Santiago P. C. <San...@yd...> - 2002-09-18 15:04:38
|
Hi *,
Simon, you can both use a char array (buffer) from the beginning or use
string and then copy the contents to a char array (buffer), anyway this i=
s a
mixed C/C++ situation:
1st)=20
#include <iostream>=20
#include <stdlib.h>
#define BUFFER_SIZE 32
int main()
{=20
char szIP[BUFFER_SIZE];
char szCommand[BUFFER_SIZE];
cout << "Enter the ip to trace:";
cin >> szIP; //enter domain-name of pc
sprintf(szCommand,"tracert %s",szIP);
system(szCommand);
system("PAUSE");
return 0;=20
}=20
Or the 2nd option)
#include <iostream>=20
#include <string>
#include <stdlib.h>
#define BUFFER_SIZE 32
char* ConvertStringToSzData(string strValue)=20
{
=09int iStrLen =3D strValue.size();
=09char* pSzData =3D (char*) malloc( (iStrLen+1)*sizeof(char) );
=09if (pSzData)
=09{
=09 strncpy(pSzData,strValue.data(),iStrLen);
=09 // NULL TERMINATED STRING ;o)
=09 pSzData[iStrLen] =3D '\0';
=09}
=09return pSzData;
}
int main()
{=20
string strIP;
char szCommand[BUFFER_SIZE];
char* pSzIP =3D NULL;
cout << "Enter the ip to trace:";
cin >> strIP; //enter domain-name of pc
pSzIP =3D ConvertStringToSzData(strIP);
if (pSzIP)
{
=09sprintf(szCommand,"tracert %s",pSzIP);
=09free(pSzIP);
=09system(szCommand);
}
else
=09cout << "ERROR: Cannot convert string to char array!" << endl;
system("PAUSE");
return 0;=20
}=20
Hope this helps!
Santy
-----Original Message-----
From: Simon Johner [mailto:el...@op...]=20
Sent: mi=E9rcoles, 18 de septiembre de 2002 16:29
To: dev...@li...
Subject: [Dev-C++] execution of a string with system()
Hello everybody,
I tried to write a programm which does execute some dos command (like
tracert, ping etc.) with an ip.
At first, I created a string (#include <string>), but when I tried to
execute it with the system()-command, I got the following error
(exec=3Dstring-Variable): "cannot convert 'exec' from type string to type=
'const char*'"
Finally -after some hours of trying :)- I've got the following solution:
#include <iostream>=20
#include <stdlib.h>
int main()
{=20
int i;
char pcno[20];
cout << "Enter the ip to trace:" , cin >> pcno; //enter domain-name of pc=
(domain-name is supposed to be 8 chars long)
for (i=3D0;i<8;i++){pcno[i+8]=3Dpcno[i];}; //put the domain name at the e=
nd
pcno[0]=3D't'; pcno[1]=3D'r'; pcno[2]=3D'a';
pcno[3]=3D'c'; //enter the dos-command in the f=
irst
chars
pcno[4]=3D'e';
pcno[5]=3D'r';
pcno[6]=3D't';
pcno[7]=3D' ';
for (i=3D16;i<40;i++){pcno[i]=3D' ';};
system(pcno);
system("PAUSE");
return 0;=20
}=20
Does someone know an easier solution?
Tanks for your help.
Simon
--=20
__________________________________________________________
Download the FREE Opera browser at www.opera.com/download/
Free OperaMail at http://www.operamail.com/
Powered by Outblaze
-------------------------------------------------------
This SF.NET email is sponsored by: AMD - Your access to the experts on
Hammer Technology! Open Source & Linux Developers, register now for the A=
MD
Developer Symposium. Code: EX8664 http://www.developwithamd.com/developer=
lab
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
-------------------------------------------------------------------------=
-------------
This message and any files transmitted with it are confidential and inten=
ded solely=20
for the use of the individual or entity to whom they are addressed. No co=
nfidentiality=20
or privilege is waived or lost by any wrong transmission.=20
If you have received this message in error, please immediately destroy it=
=20and kindly=20
notify the sender by reply email.
You must not, directly or indirectly, use, disclose, distribute, print, o=
r copy any=20
part of this message if you are not the intended recipient. Opinions, con=
clusions and=20
other information in this message that do not relate to the official busi=
ness of=20
Ydilo Advanced Voice Solutions, S.A. shall be understood as neither given=
=20nor endorsed by it.=20
-------------------------------------------------------------------------=
-------------
|
|
From: The Tone's. <to...@ds...> - 2002-09-18 14:51:15
|
all, to those that responded, thanks. Now that I understand the distinction between the GNU libc and the GNU GCC suite, a few things have clarified. I am working on a console app that will be parsing through several ASCII text files, of differing format, where the "records" in these files can vary on a line by line basis. according to a handful of rules. The format is not under my control. Can anyone recommend a nice, tight, chunk of code written in 'C' that will make my life easier for reading strings from files, pattern matching and string manipulation ? TIA, Tony ===== |
|
From: Christian W. <Chr...@vo...> - 2002-09-18 14:48:28
|
Hi Simon,
I have done it this way:
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
int main(int argc, char* argv[])
{
char szShellCmd[200];
strnset(szShellCmd, 0, sizeof(szShellCmd));
strcpy(szShellCmd, "dir *.*\0");
system(szShellCmd);
getchar();
return 0;
};
and it works.
Kind r
Christian
|
|
From: Simon J. <el...@op...> - 2002-09-18 14:29:01
|
Hello everybody,
I tried to write a programm which does execute some dos command (like tracert, ping etc.) with an ip.
At first, I created a string (#include <string>), but when I tried to execute it with the system()-command, I got the following error (exec=string-Variable):
"cannot convert 'exec' from type string to type 'const char*'"
Finally -after some hours of trying :)- I've got the following solution:
#include <iostream>
#include <stdlib.h>
int main()
{
int i;
char pcno[20];
cout << "Enter the ip to trace:" , cin >> pcno; //enter domain-name of pc (domain-name is supposed to be 8 chars long)
for (i=0;i<8;i++){pcno[i+8]=pcno[i];}; //put the domain name at the end
pcno[0]='t';
pcno[1]='r';
pcno[2]='a';
pcno[3]='c'; //enter the dos-command in the first chars
pcno[4]='e';
pcno[5]='r';
pcno[6]='t';
pcno[7]=' ';
for (i=16;i<40;i++){pcno[i]=' ';};
system(pcno);
system("PAUSE");
return 0;
}
Does someone know an easier solution?
Tanks for your help.
Simon
--
__________________________________________________________
Download the FREE Opera browser at www.opera.com/download/
Free OperaMail at http://www.operamail.com/
Powered by Outblaze
|
|
From: Carlos d. M. <cg...@wo...> - 2002-09-18 11:57:48
|
Per Westermark escribi=F3: > Forst of all, I didn't know that overload existed in C. Sorry, my english is not perfect, I got the "license" of saying overload,= I noticed it would be best not having it after sending. Er, today is my dumb day, it s= eems > > > Second. Why write a new getline with - almost - the same function as > the already existing fgets? I have the cpluplus reference, and by it and the name fgets is for workin= g for files (I should have add it) but I assumed the question was about stdin. > > > Third. The sample code never terminates the loaded buffer after it find= s z > newline character, or runs out of buffer space. Ouch! I had the feeling of forgetting something. buffer[size] =3D '\0'; It shouldn't run out of buffer, the parameter is given. (well, size =3D l= ast non \0 index +1) (I didn't test it) > > > I was trying to use the "getline()" function in the GCC/GNU distro = as included > > > in Dev-Cpp v5 beta. > > > > > > I was getting an error from the linker. > > > > > > I looked into the <iostream.h>. > > > > > > This appears to be a C++ header. > > > > > > I am developing/compiling as 'C'. > > > > > > I tried it anyway. > > > > > > compile errors. to be expected. > > > > > > The GCC docs seem to imply that this is a <stdio.h> function that c= an be used > > > from 'C' code ? > > > > > > ??? > > > > > > TIA, > > > Tony > > > > > > --- Carlos Garc=EDa del Monte <cg...@wo...> wrote: > > > > #include <iostream.h> > > > > > > =3D=3D=3D=3D=3D > > > > > > ------------------------------------------------------- > > > This SF.NET email is sponsored by: AMD - Your access to the experts > > > on Hammer Technology! Open Source & Linux Developers, register now > > > for the AMD Developer Symposium. Code: EX8664 > > > http://www.developwithamd.com/developerlab > > > _______________________________________________ > > > Dev-cpp-users mailing list > > > Dev...@li... > > > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > ------------------------------------------------------- > > This SF.NET email is sponsored by: AMD - Your access to the experts > > on Hammer Technology! Open Source & Linux Developers, register now > > for the AMD Developer Symposium. Code: EX8664 > > http://www.developwithamd.com/developerlab > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > |
|
From: Per W. <pw...@ia...> - 2002-09-18 11:10:59
|
Forst of all, I didn't know that overload existed in C.
Second. Why write a new getline with - almost - the same function as
the already existing fgets?
Third. The sample code never terminates the loaded buffer after it finds z
newline character, or runs out of buffer space.
/Per W
On Wed, 18 Sep 2002, Carlos Garc=EDa del Monte wrote:
> Oh, yes, iostream is C++, I should have notice it, stdio has no getline.
> There are no C getline(), only C++, the one from iostream and the other w=
hich come
> from string and the other string classes. And get is either from iostream=
=2E
>=20
> You can make your own getline, overload it
> void getline(char *buffer, int size){
> char test =3D 'a';
> for (int i =3D 0; i < size && test !=3D '\n'; i++){
> buffer[i] =3D get();
> test =3D buffer[i];
> }
> }
>=20
> The Tone'ster escribi=F3:
>=20
> > To recap :
> >
> > I was trying to use the "getline()" function in the GCC/GNU distro as i=
ncluded
> > in Dev-Cpp v5 beta.
> >
> > I was getting an error from the linker.
> >
> > I looked into the <iostream.h>.
> >
> > This appears to be a C++ header.
> >
> > I am developing/compiling as 'C'.
> >
> > I tried it anyway.
> >
> > compile errors. to be expected.
> >
> > The GCC docs seem to imply that this is a <stdio.h> function that can b=
e used
> > from 'C' code ?
> >
> > ???
> >
> > TIA,
> > Tony
> >
> > --- Carlos Garc=EDa del Monte <cg...@wo...> wrote:
> > > #include <iostream.h>
> >
> > =3D=3D=3D=3D=3D
> >
> > -------------------------------------------------------
> > This SF.NET email is sponsored by: AMD - Your access to the experts
> > on Hammer Technology! Open Source & Linux Developers, register now
> > for the AMD Developer Symposium. Code: EX8664
> > http://www.developwithamd.com/developerlab
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>=20
>=20
>=20
> -------------------------------------------------------
> This SF.NET email is sponsored by: AMD - Your access to the experts
> on Hammer Technology! Open Source & Linux Developers, register now
> for the AMD Developer Symposium. Code: EX8664
> http://www.developwithamd.com/developerlab
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>=20
|
|
From: Santiago P. C. <San...@yd...> - 2002-09-18 11:08:06
|
Hi John,
Please take a closer look to:
- function calling mechanism and return Values,
- variables scopes,
- passing variables by reference or by value,
In your code you are...
1st) ...Passing variables by value _NOT_BY_REFERENCE_ so you cannot modif=
y
its value inside the function you are passing the variable to.
=09int FirstNumber(int NumberOne)
=09{
=09 cout << "Enter how much money you had this morning $";
=09 cin >> NumberOne; // <=3D this NumberOne is NOT
the same as main's NumberOne
=09}
2nd) ..."Mixing" the way a variable is defined and the way that variable'=
s
content is handled.
=09int ThirdNumber(int NumberThree)
=09{
=09 // NumberThree =3D int NumberOne - int NumberTwo; // <=3D WRONG
STATEMENT
=09 // you are "trying to define" 'NumberOne' and
'NumberTwo' erroneously and in a local scope,
=09 // please have in mind that you are not referencing
main's 'NumberOne' and 'NumberTwo'
=09 cout << "You have spent $" << NumberThree << " dollars today " <<
endl;
=09}
3rd) ...defining functions to return an int value but not returning it:
=09int FirstNumber(int NumberOne)
=09{
=09 cout << "Enter how much money you had this morning $";
=09 cin >> NumberOne; // <=3D this NumberOne is NOT
the same as main's NumberOne
=09 // There must be a return statement here!!!!
=09}
4th) ..."thinking" that you are calling functions while you're NOT doing
that...
// Main Function
int main(int argc, char *argv[])
{
=20 int NumberOne;
=20 int NumberTwo;
=20 int NumberThree;
=09// Here you are "trying to REdefine" the functions, NOT calling
them
=20 int FirstNumber(int NumberOne); =09
=20 int SecondNumber(int NumberTwo);
=20 int ThirdNumber(int NumberThree);
=20 system("PAUSE");
=20 return 0;
}
There are also some "design issues" that I think you should take a look a=
t;
so I've modified your code the way I think it should look like (I've
modified some names in order to clarify the code ;oD):
#include <iostream>
#include <string>
/*
This program in designed to take input from the user,
in the form of a number and compute the output.
The program is then to display the output back to the user.
*/
// Function Definitions
int GetFirstNumber(); =20
int GetSecondNumber(); =20
void ShowThirdNumber(int iNumberOne, int iNumberTwo);
// GetFirstNumber Function
// The function gets an input from the user and returns it
int GetFirstNumber()
{
=20 int iLocalNumberOne =3D 0;
=20 cout << "Enter how much money you had this morning:" << endl ;
=20 cin >> iLocalNumberOne;
=20 return iLocalNumberOne;
}
// GetSecondNumber Function
// The function gets an input from the user and returns it
int GetSecondNumber()
{
=20 int iLocalNumberTwo =3D 0;
=20 cout << "Enter how much money you have now:" << endl;
=20 cin >> iLocalNumberTwo;
=20return iLocalNumberTwo;
}
// ShowThirdNumber Function
void ShowThirdNumber(int iNumberOne, int iNumberTwo)
{
=20 int iLocalNumberThree =3D iNumberOne - iNumberTwo;
=20 cout << "You have spent " << iLocalNumberThree << " dollars today " <=
<
endl;
}
// Main Function
int main(int argc, char *argv[])
{
=09// Retrieve first Number by calling the appropriate function and
=09// store it at int variable called 'iTheFirstNumber'
=09int iTheFirstNumber =3D GetFirstNumber();
=09// Retrieve second Number by calling the appropriate function and
=09// store it at int variable called 'iTheSecondNumber'
=09int iTheSecondNumber =3D GetSecondNumber();
=09// Call the apropriate function with the previously acquired values
=09// in order to print the result to the screen
=09ShowThirdNumber(iTheFirstNumber, iTheSecondNumber);
=20 system("PAUSE");
=20 return 0;
}
Hope this helps!!!
Regards, Santy
-----Original Message-----
From: John Ellison [mailto:j_...@ip...]=20
Sent: mi=E9rcoles, 18 de septiembre de 2002 12:00
To: dev...@li...
Subject: [Dev-C++] Newbie Needs Help
Gudday All,
=20 I have a small problem which I cant seem to find the answer to. I w=
as
hoping that someone could help. I am just beginning to learn c++, so the
code is not to complex. My problem lies in the compilation process. I am
unsure as to how to fix the compilation error.
Thanks to everybody.
Have a good one.
John
Here is the compilation error.
32 six.cpp parse error before `-'
And here is my source code :-
#include <stdio.h>
#include <iostream>
#include <string>
/*
This program in designed to take input from the user,
in the form of a number and compute the output.
The program is then to display the output back to the user.
*/
int FirstNumber(int NumberOne); // Function Definitions
int SecondNumber(int NumberTwo); // Function Definitions
int ThirdNumber(int NumberThree); // Function Definitions
// FirstNumber Function
int FirstNumber(int NumberOne)
{
=20 cout << "Enter how much money you had this morning $";
=20 cin >> NumberOne;
}
// SecondNumber Function
int SecondNumber(int NumberTwo)
{
=20 cout << "Enter how much money you have now $";
=20 cin >> NumberTwo;
}
// ThirdNumber Function
int ThirdNumber(int NumberThree)
{
=20 NumberThree =3D int NumberOne - int NumberTwo;
=20 cout << "You have spent $" << NumberThree << " dollars today " << end=
l;
}
// Main Function
int main(int argc, char *argv[])
{
=20 int NumberOne;
=20 int NumberTwo;
=20 int NumberThree;
=20 int FirstNumber(int NumberOne);
=20 int SecondNumber(int NumberTwo);
=20 int ThirdNumber(int NumberThree);
=20 system("PAUSE");
=20 return 0;
}
=20
-------------------------------------------------------------------------=
-------------
This message and any files transmitted with it are confidential and inten=
ded solely=20
for the use of the individual or entity to whom they are addressed. No co=
nfidentiality=20
or privilege is waived or lost by any wrong transmission.=20
If you have received this message in error, please immediately destroy it=
=20and kindly=20
notify the sender by reply email.
You must not, directly or indirectly, use, disclose, distribute, print, o=
r copy any=20
part of this message if you are not the intended recipient. Opinions, con=
clusions and=20
other information in this message that do not relate to the official busi=
ness of=20
Ydilo Advanced Voice Solutions, S.A. shall be understood as neither given=
=20nor endorsed by it.=20
-------------------------------------------------------------------------=
-------------
|
|
From: Gaetan K. <gk...@et...> - 2002-09-18 10:42:55
|
>> Hi, how does auto-indent work? >It works fine here under v 4.9.4.1 I'm using 4.9.5.3 |
|
From: Ramana K. <ra...@my...> - 2002-09-18 10:40:53
|
You do not use the type "int" when you are using the - operator:
NumberThree = int NumberOne - int NumberTwo;
is wrong syntax.
you need instead:
NumberThree = NumberOne - NumberTwo;
but for this to work, the function ThirdNumber(int) needs to take NumberOne
and NumberTwo as parameters.
so you need to put
ThirdNumber(int,int,int);
as the definition. and in the main function, you call it like this:
ThirdNumber(NumberThree,NumberTwo,NumberOne);
you do not call functions with their return type and argument types either:
int FirstNumber(int NumberOne);
is wrong syntax (this is the call, not the definition).
you need instead:
FirstNumber(NumberOne);
you also need to use references, because the data you get from the user does
not survive the local scope of the function.
maybe i just write out your program correctly, removing syntax errors (but
not improving code):
#include <stdio.h>
#include <iostream>
#include <string>
/*
This program in designed to take input from the user,
in the form of a number and compute the output.
The program is then to display the output back to the user.
*/
int FirstNumber(int&); // Function Definitions
int SecondNumber(int&); // Function Definitions
int ThirdNumber(int,int,int); // Function Definitions
// FirstNumber Function
int FirstNumber(int NumberOne)
{
cout << "Enter how much money you had this morning $";
cin >> NumberOne;
}
// SecondNumber Function
int SecondNumber(int NumberTwo)
{
cout << "Enter how much money you have now $";
cin >> NumberTwo;
}
// ThirdNumber Function
int ThirdNumber(int NumberThree, int NumberTwo, int NumberOne)
{
NumberThree = int NumberOne - int NumberTwo;
cout << "You have spent $" << NumberThree << " dollars today " << endl;
}
// Main Function
int main(int argc, char *argv[])
{
int NumberOne;
int NumberTwo;
int NumberThree;
FirstNumber(NumberOne);
SecondNumber(NumberTwo);
ThirdNumber(NumberThree,NumberTwo,NumberOne);
system("PAUSE");
return 0;
}
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...]On Behalf Of John Ellison
Sent: Wednesday, 18 September 2002 8:00 PM
To: dev...@li...
Subject: [Dev-C++] Newbie Needs Help
Gudday All,
I have a small problem which I cant seem to find the answer to. I was
hoping that someone could help. I am just beginning to learn c++, so the
code is not to complex. My problem lies in the compilation process. I am
unsure as to how to fix the compilation error.
Thanks to everybody.
Have a good one.
John
Here is the compilation error.
32 six.cpp parse error before `-'
And here is my source code :-
#include <stdio.h>
#include <iostream>
#include <string>
/*
This program in designed to take input from the user,
in the form of a number and compute the output.
The program is then to display the output back to the user.
*/
int FirstNumber(int NumberOne); // Function Definitions
int SecondNumber(int NumberTwo); // Function Definitions
int ThirdNumber(int NumberThree); // Function Definitions
// FirstNumber Function
int FirstNumber(int NumberOne)
{
cout << "Enter how much money you had this morning $";
cin >> NumberOne;
}
// SecondNumber Function
int SecondNumber(int NumberTwo)
{
cout << "Enter how much money you have now $";
cin >> NumberTwo;
}
// ThirdNumber Function
int ThirdNumber(int NumberThree)
{
NumberThree = int NumberOne - int NumberTwo;
cout << "You have spent $" << NumberThree << " dollars today " << endl;
}
// Main Function
int main(int argc, char *argv[])
{
int NumberOne;
int NumberTwo;
int NumberThree;
int FirstNumber(int NumberOne);
int SecondNumber(int NumberTwo);
int ThirdNumber(int NumberThree);
system("PAUSE");
return 0;
}
|
|
From: metalseb <met...@fr...> - 2002-09-18 10:27:17
|
> // ThirdNumber Function
> int ThirdNumber(int NumberThree)
> {
> NumberThree = int NumberOne - int NumberTwo;
> cout << "You have spent $" << NumberThree << " dollars today " << endl;
> }
The compiler doesn't know what to do with this code gathering two declarations of int vars
minusing themselves at the same time. Remove that line.
Remember that NumberOne and NumberTwo are not global vars so they are not known inside
the ThirdNumber function. Only in the main section, where they are declared. By the way,
remove the int return values of each function since they don't do anything but asking for a user
input.
All you have to do in the main section is :
ThirdNumber(NumberTwo-NumberOne);
And in the ThirdNumber func :
void ThirdNumber(int NumberThree)
{
cout << "You have spent $" << NumberThree << " dollars today " << endl;
}
Kind regards
--
Seb
|
|
From: metalseb <met...@fr...> - 2002-09-18 10:27:13
|
> Hi, how does auto-indent work? It works fine here under v 4.9.4.1 -- Seb |
|
From: John E. <j_...@ip...> - 2002-09-18 10:04:54
|
Gudday All,
I have a small problem which I cant seem to find the answer to. I was
hoping that someone could help. I am just beginning to learn c++, so the
code is not to complex. My problem lies in the compilation process. I am
unsure as to how to fix the compilation error.
Thanks to everybody.
Have a good one.
John
Here is the compilation error.
32 six.cpp parse error before `-'
And here is my source code :-
#include <stdio.h>
#include <iostream>
#include <string>
/*
This program in designed to take input from the user,
in the form of a number and compute the output.
The program is then to display the output back to the user.
*/
int FirstNumber(int NumberOne); // Function Definitions
int SecondNumber(int NumberTwo); // Function Definitions
int ThirdNumber(int NumberThree); // Function Definitions
// FirstNumber Function
int FirstNumber(int NumberOne)
{
cout << "Enter how much money you had this morning $";
cin >> NumberOne;
}
// SecondNumber Function
int SecondNumber(int NumberTwo)
{
cout << "Enter how much money you have now $";
cin >> NumberTwo;
}
// ThirdNumber Function
int ThirdNumber(int NumberThree)
{
NumberThree = int NumberOne - int NumberTwo;
cout << "You have spent $" << NumberThree << " dollars today " << endl;
}
// Main Function
int main(int argc, char *argv[])
{
int NumberOne;
int NumberTwo;
int NumberThree;
int FirstNumber(int NumberOne);
int SecondNumber(int NumberTwo);
int ThirdNumber(int NumberThree);
system("PAUSE");
return 0;
}
|
|
From: Carlos d. M. <cg...@wo...> - 2002-09-18 09:00:36
|
Oh, yes, iostream is C++, I should have notice it, stdio has no getline.
There are no C getline(), only C++, the one from iostream and the other w=
hich come
=66rom string and the other string classes. And get is either from iostre=
am.
You can make your own getline, overload it
void getline(char *buffer, int size){
char test =3D 'a';
for (int i =3D 0; i < size && test !=3D '\n'; i++){
buffer[i] =3D get();
test =3D buffer[i];
}
}
The Tone'ster escribi=F3:
> To recap :
>
> I was trying to use the "getline()" function in the GCC/GNU distro as i=
ncluded
> in Dev-Cpp v5 beta.
>
> I was getting an error from the linker.
>
> I looked into the <iostream.h>.
>
> This appears to be a C++ header.
>
> I am developing/compiling as 'C'.
>
> I tried it anyway.
>
> compile errors. to be expected.
>
> The GCC docs seem to imply that this is a <stdio.h> function that can b=
e used
> from 'C' code ?
>
> ???
>
> TIA,
> Tony
>
> --- Carlos Garc=EDa del Monte <cg...@wo...> wrote:
> > #include <iostream.h>
>
> =3D=3D=3D=3D=3D
>
> -------------------------------------------------------
> This SF.NET email is sponsored by: AMD - Your access to the experts
> on Hammer Technology! Open Source & Linux Developers, register now
> for the AMD Developer Symposium. Code: EX8664
> http://www.developwithamd.com/developerlab
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Gaetan K. <gk...@et...> - 2002-09-18 08:48:10
|
Hi, how does auto-indent work? I marked the checkbox but it doesn't do anything. (shouldn't it indent a line after I press ENTER?) thanx |
|
From: Per W. <pw...@ia...> - 2002-09-18 07:05:08
|
You can still use fgets. It's just the gets that must not be used, since it doesn't take the size of the input buffer as a parameter. /Per W On Tue, 17 Sep 2002, The Tone'ster wrote: >=20 > uhh ... >=20 > I think I get it now. >=20 > These functions are actually part of the "GNU libc" ... not part of the G= NU > compiler suite and any runtime libs it contains ? >=20 > so ... I would need to have this stuff, and it looks like the source is n= ot > portable to windows ? >=20 > Tony >=20 > --- The Tone'ster <to...@ds...> wrote: > >=20 > > To recap : > >=20 > > I was trying to use the "getline()" function in the GCC/GNU distro as > > included > > in Dev-Cpp v5 beta. > >=20 > > I was getting an error from the linker. > >=20 > > I looked into the <iostream.h>. > >=20 > > This appears to be a C++ header. > >=20 > > I am developing/compiling as 'C'. > >=20 > > I tried it anyway. > >=20 > > compile errors. to be expected. > >=20 > > The GCC docs seem to imply that this is a <stdio.h> function that can b= e used > > from 'C' code ? > >=20 > > ??? > >=20 > > TIA, > > Tony > >=20 > > --- Carlos Garc=EDa del Monte <cg...@wo...> wrote: > > > #include <iostream.h> > >=20 > > =3D=3D=3D=3D=3D > >=20 > >=20 > >=20 > > ------------------------------------------------------- > > This SF.NET email is sponsored by: AMD - Your access to the experts > > on Hammer Technology! Open Source & Linux Developers, register now > > for the AMD Developer Symposium. Code: EX8664 > > http://www.developwithamd.com/developerlab > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >=20 >=20 > =3D=3D=3D=3D=3D >=20 >=20 >=20 > ------------------------------------------------------- > This SF.NET email is sponsored by: AMD - Your access to the experts > on Hammer Technology! Open Source & Linux Developers, register now > for the AMD Developer Symposium. Code: EX8664 > http://www.developwithamd.com/developerlab > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >=20 |
|
From: The Tone's. <to...@ds...> - 2002-09-18 02:41:52
|
uhh ... I think I get it now. These functions are actually part of the "GNU libc" ... not part of the GNU compiler suite and any runtime libs it contains ? so ... I would need to have this stuff, and it looks like the source is not portable to windows ? Tony --- The Tone'ster <to...@ds...> wrote: > > To recap : > > I was trying to use the "getline()" function in the GCC/GNU distro as > included > in Dev-Cpp v5 beta. > > I was getting an error from the linker. > > I looked into the <iostream.h>. > > This appears to be a C++ header. > > I am developing/compiling as 'C'. > > I tried it anyway. > > compile errors. to be expected. > > The GCC docs seem to imply that this is a <stdio.h> function that can be used > from 'C' code ? > > ??? > > TIA, > Tony > > --- Carlos García del Monte <cg...@wo...> wrote: > > #include <iostream.h> > > ===== > > > > ------------------------------------------------------- > This SF.NET email is sponsored by: AMD - Your access to the experts > on Hammer Technology! Open Source & Linux Developers, register now > for the AMD Developer Symposium. Code: EX8664 > http://www.developwithamd.com/developerlab > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users ===== |
|
From: The Tone's. <to...@ds...> - 2002-09-17 21:06:16
|
To recap : I was trying to use the "getline()" function in the GCC/GNU distro as included in Dev-Cpp v5 beta. I was getting an error from the linker. I looked into the <iostream.h>. This appears to be a C++ header. I am developing/compiling as 'C'. I tried it anyway. compile errors. to be expected. The GCC docs seem to imply that this is a <stdio.h> function that can be used from 'C' code ? ??? TIA, Tony --- Carlos García del Monte <cg...@wo...> wrote: > #include <iostream.h> ===== |
|
From: <mi...@su...> - 2002-09-17 17:53:20
|
Where I can found a c++ complete source code for screensaver (WIN32)? I built a program for statistics: download it to http://mis.supereva.it I apologize for my english (I'm Italian). bye ----------------------------------------------------- Invia una cartolina ad un amico! http://cartoline.supereva.it/index.html messaggio inviato con Freemail by www.superEva.it ----------------------------------------------------- |
|
From: Carlos d. M. <cg...@wo...> - 2002-09-17 16:34:14
|
For what I read, it's due to billion defines. The Tone'ster escribi=F3: > hi, > > noob here again. > > I notice that simply doing a #include <windows.h> increases my executab= le size > by some 250k without touching any functions in my code within WIN32. > > Again, I am a Java programmer, so I am trying to get my head around how= this > stuff works. > > Is this increase in size due to needing a larger 'text' segment for all= of the > stuff defined in <windows.h> and the 5 zillion #includes it pulls in ? > > Or ... is this because libs or something are getting statically linked = into the > executable ? > > TIA, > Tony > > =3D=3D=3D=3D=3D > > ------------------------------------------------------- > Sponsored by: AMD - Your access to the experts on Hammer Technology! > Open Source & Linux Developers, register now for the AMD Developer > Symposium. Code: EX8664 http://www.developwithamd.com/developerlab > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
|
From: Per W. <pw...@ia...> - 2002-09-17 16:25:15
|
When compiling with debug information on, every new include file results in larger executable. windows.h isn't any include file. It is THE include file. It continues to include a lot of other windows files. /Per W On Tue, 17 Sep 2002, The Tone'ster wrote: > > hi, > > noob here again. > > I notice that simply doing a #include <windows.h> increases my executable size > by some 250k without touching any functions in my code within WIN32. > > Again, I am a Java programmer, so I am trying to get my head around how this > stuff works. > > Is this increase in size due to needing a larger 'text' segment for all of the > stuff defined in <windows.h> and the 5 zillion #includes it pulls in ? > > Or ... is this because libs or something are getting statically linked into the > executable ? > > TIA, > Tony > > ===== > > > > ------------------------------------------------------- > Sponsored by: AMD - Your access to the experts on Hammer Technology! > Open Source & Linux Developers, register now for the AMD Developer > Symposium. Code: EX8664 http://www.developwithamd.com/developerlab > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: The Tone's. <to...@ds...> - 2002-09-17 14:52:17
|
hi, noob here again. I notice that simply doing a #include <windows.h> increases my executable size by some 250k without touching any functions in my code within WIN32. Again, I am a Java programmer, so I am trying to get my head around how this stuff works. Is this increase in size due to needing a larger 'text' segment for all of the stuff defined in <windows.h> and the 5 zillion #includes it pulls in ? Or ... is this because libs or something are getting statically linked into the executable ? TIA, Tony ===== |
|
From: The Tone's. <to...@ds...> - 2002-09-17 14:42:29
|
yeah. this is what the doc for GCC said, thus my attempt to use the alternative getline(). somebody else suggested #include <iostream.h>. I'll try this. The GCC doc said that this function was part of <stdio.h>. Cheers, Tony --- Per Westermark <pw...@ia...> wrote: > Forget any mention of a gets() function. It should N.E.V.E.R. be used > because of buffer overflow problems. > > /Per W > > On Mon, 16 Sep 2002, PhrostByte wrote: > > > Maybe your looking for gets() and fgets()? > > ===== |
|
From: Daniel G. <sp...@ho...> - 2002-09-17 12:46:25
|
There was somebody who had a site hosting the libraries (those .a files) that you need to run directX 8 HOWEVER I found I could only run very VERY basic apps (like the first 2 samples that come with the SDK) using the previous version of DEV and had to buy Visual C++ 6.0 in order to get anything else working. I needed it as I was trying to get a programming job, which did help me in the end but not with video game companies - unless you have tons of experience (as with most jobs, especially programming) you're not getting in. And recruitment agencies mislead you, or just don't know the first thing about getting programming jobs. Ugh, I hate recruiters. P.S. I've had probs sending this email to the list. _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx |