dev-cpp-users Mailing List for Dev-C++ (Page 541)
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: Carlos d. M. <cg...@wo...> - 2002-08-08 18:40:26
|
I saw a contest I thought iteresting to do, I wrote this:
This compiles:
#include <stdiostream.h>
#include <stdlib.h>
#include <math.h>
#include <iso646.h>
short int compare(const long int, const long int);
int main()
{
long int a = 45, b = 54, x = 3, y=3, m=56, n=32;
int res;
printf("%ld-%ld= %hd\n%ld-%ld=%hd\n%ld-%ld=%hd", a, b, compare(a,b), x,
y, compare(x,y), m, n, compare(m,n));
system("PAUSE");
return 0;
}
short int compare(const long int first, const long int second){
long int res1, res2 = 2, res3, unsi;
short int result = 0;
res1 = second - first;
res1 >>= 30;
unsi = res1 ^ res2;
res3 = second - first - 1;
res3 >>= 30;
res3 ^= res2;
unsi &= res3;
result = 2 - unsi;
return result;
}
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
This don't (variables of the function are considered not declared from
line 25):
#include <stdiostream.h>
#include <stdlib.h>
#include <math.h>
#include <iso646.h>
short int compare(const long int, const long int);
int main()
{
long int a = 45, b = 54, x = 3, y=3, m=56, n=32;
int res;
printf("%ld-%ld= %hd\n%ld-%ld=%hd\n%ld-%ld=%hd", a, b, compare(a,b), x,
y, compare(x,y), m, n, compare(m,n));
system("PAUSE");
return 0;
}
short int compare(const long int first, const long int second){
long int res1, res2 = 2, res3, unsi;
short int result = 0;
res1 = second - first;
res1 >>= 30;
unsi = res1 xor res2; <-- line 25 not declared
res3 = second - first - 1;
res3 >>= 30;
res3 xor_eq res2;
unsi and_eq res3;
result = 2 - unsi;
return result;
}
Yes, I know there is people who do not like systempause.
|
|
From: Carlos d. M. <cg...@wo...> - 2002-08-08 18:35:50
|
> Great! As you see it was not a compiler's issue. Great! Yes! Now I've found and reviewed one piece of code which has the for(int i) I said it didn't work. It is an author error (author of some code example I used). The ANSI about declaring for is something like "you can declare inside a for statement in the way (int i = 0[...]), but you can't use it later outside it, if you want you have to declare it just before the for: int i; for(i=0[...]) or redeclare it". I read first C/C++, an old edition and centered in C, so it said nothing about possibility of declaring in the for. Later I bought the "C++ how to program" (which couple of inexactitudes I found, some misleading things about bitfields, I suspect are due to the translator (I bought it in spanish) who knows bad spanish (!!!)), but I knew for, and I only noticed "can be declared in", but not read "out of it it is out of scope". And later I got some code examples from some sites (I don't remember where) where they were used later, and that misled me, thinking that the error wasn't only outside, but inside, too. It's a bad thing that the last for/while rare thing is deleted. I would see a possibly frequent error. (or you a compiler strange behavior, hehehehe) and I would learn to see a error now I am unable to see (Feel I need a phrase about the sea being free). Greets. |
|
From: Ioannis V. <no...@ho...> - 2002-08-08 14:38:21
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf=20 > Of Carlos Garc=EDa del Monte > Sent: Thursday, August 08, 2002 2:25 PM > To: dev-cpp-users-list > Subject: Re: [Dev-C++] compiler psychiatrics >=20 >=20 > The two bad comments were not in the original, I added them in the > message. The // was an explanation for you about where the=20 > fail was, and > since I write almost everything in C++ now I use //always. If so the > compiler would have say errors errors errors!!! and bad comment. The > other that interrupts is either added in the message (sorry,=20 > I had to be > more carefully, although being in a message, it was for be=20 > compiled, so > I had to notice they would give you errors if you try). > Yeah! Those damned \n. I forgot that this experiment was the=20 > last before > abandoning that custom of \n in scanfs (it was my second experiment > while learning programming) and that I deleted the correction and left > the original with \n (I did not reached to try the correction which > works fine). And so I was not observant of that error, when I=20 > saw a \n I > thought "printf"... and went on. > Without it it works fine. > All the other strange behavior (or possible strange, of course) are > corrected and I don't have any of them at hand. Great! As you see it was not a compiler's issue. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |
|
From: Hongli L. <h....@ch...> - 2002-08-08 11:55:04
|
On Thu, 2002-08-08 at 13:09, Met...@ao... wrote: > It's nice ! > > I didn't know that was possible. > > Hongli, I think you have a problem with you mail client, as each time you > post, we can see your mails two times > That's because I hit Reply to All. |
|
From: Carlos d. M. <cg...@wo...> - 2002-08-08 11:30:10
|
The two bad comments were not in the original, I added them in the message. The // was an explanation for you about where the fail was, and since I write almost everything in C++ now I use //always. If so the compiler would have say errors errors errors!!! and bad comment. The other that interrupts is either added in the message (sorry, I had to be more carefully, although being in a message, it was for be compiled, so I had to notice they would give you errors if you try). Yeah! Those damned \n. I forgot that this experiment was the last before abandoning that custom of \n in scanfs (it was my second experiment while learning programming) and that I deleted the correction and left the original with \n (I did not reached to try the correction which works fine). And so I was not observant of that error, when I saw a \n I thought "printf"... and went on. Without it it works fine. All the other strange behavior (or possible strange, of course) are corrected and I don't have any of them at hand. |
|
From: <qa...@ho...> - 2002-08-08 11:19:23
|
Hmmm. Strange! I don't receive multiple postings from Hongli... /J *********** REPLY SEPARATOR *********** On 2002-08-08 at 07:09 Met...@ao... wrote: It's nice ! I didn't know that was possible. Hongli, I think you have a problem with you mail client, as each time you= post, we can see your mails two times Kind regards -- Seb |
|
From: <Met...@ao...> - 2002-08-08 11:09:27
|
It's nice ! I didn't know that was possible. Hongli, I think you have a problem with you mail client, as each time you post, we can see your mails two times Kind regards -- Seb |
|
From: Hongli L. <h....@ch...> - 2002-08-08 10:25:29
|
On Thu, 2002-08-08 at 10:27, Met...@ao... wrote: >> I want to look through the assembly code of my c++ program,how to >> generate ? > > Just download a freeware disassembler and look at the exe generated by DevCpp There's no need to do that! The compiler can generate readable assembly code for you. Add -S to Project Options->Compiler Options. Linking will probably fail, but you will see the assembly code in the .o files. |
|
From: Zodiaq <zo...@ac...> - 2002-08-08 09:31:55
|
Hello Teodorescu and all Dev-C++ users, Thursday, August 8, 2002, 9:16:09 AM, Teodorescu wrote as follows: TC> Depends on what kind of monitoring to you want. TC> The simple monitoring is no of packet send / recieve and this wou can do TC> by click on open connection :-) in system tray. Yeah, I know about that, and I know about perfmon... but I just want write something similar by my own - something to show me bytes received and send, nothing more... so I have to build driver for that? Or are there any simplier methods? -- regards, Zodiaq |
|
From: <Met...@ao...> - 2002-08-08 08:28:06
|
Just download a freeware disassembler and look at the exe generated by DevCpp Kind regards -- Seb |
|
From: Ioannis V. <no...@ho...> - 2002-08-08 08:27:39
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Daniel K. O.
> Sent: Thursday, August 08, 2002 2:34 AM
> To: Dev-Cpp-Users
> Subject: Re: [Dev-C++] compiler psychiatrics
>
> When scanf() can't find the non white space caracter, it
> normally finish,
> and some caracters can remain in the keyboard buffer, so it
> will mess with
> another scanf() calls if you don't use fflush(stdin) before them.
Although widely used, fflush(stdin) has undefined behaviour. fflush() is
made to work with output streams, not input. So it may crash your PC or
cause some acccident. You do not want that, do you?
So if you want to flush stdin you have to use something like that:
void stdinflush(void)
{
while(getchar()!='\n')
;
}
A working example:
#include <stdio.h>
void stdinflush(void)
{
while(getchar()!='\n')
;
}
int main(void)
{
char c;
scanf("%c", &c);
stdinflush();
printf("\nYou entered: %c\n", c);
return 0;
}
Another thing is that scanf() is dangerous and should be avoided if
possible.
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
* Alternative URL: http://run.to/noicys
|
|
From: xiaofei <zs...@ya...> - 2002-08-08 08:25:25
|
=09I want to look through the assembly code of my c++ program,how= to generate ? =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =09=09=09=09 =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1xiaofei =A1=...@ya... =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A12002-08-08 |
|
From: Ioannis V. <no...@ho...> - 2002-08-08 08:15:49
|
I assume you coded in C.=20
=20
=20
=20
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Carlos
Garc=EDa del Monte
Sent: Wednesday, August 07, 2002 9:44 PM
To: dev-cpp-users-list
Subject: [Dev-C++] compiler psychiatrics
Here is an old experiment for programming, when I still did not know
C++, (only a piece of the program, so I don't get you buried under a ton
of code). You run fine?=20
There are two lines, in red, that invert their order, the scanf is done
before its printf.=20
printf("and then choose the weight\n");//THESE TWO LINES CHANGE THE
ORDERING!!!!!=20
scanf("%d\n", &weight);=20
You see (adding two lines before)=20
___________________________________=20
| Title _0X |=20
|-----------------------------------------------|=20
| [...] |
| Choose the height. |=20
| 180 |=20
| _ |=20
|___________________________________|=20
The program asks for the height, you enter the height you want, 180, and
then you wait the next prompt for the weight, but you find there is the
cursor one line below, waiting your input...=20
___________________________________=20
| Title _0X |=20
|-----------------------------------------------|=20
| Choose the height. |=20
| 180 |=20
| 80 |=20
| And then choose the weight |=20
|___________________________________|=20
And you enter any number, then the prompt appears, and from now on all
inputs are before its prompt. When the moment arrives when the program
prints your character's statistics you see what went where. It continues
doing so till the end.=20
Copying the scanf after the printf and having two scanf only makes the
error repeat in the next pair printf/scanf=20
The best is that it happens when I compile it with borland 5.5.=20
/*a text-based fighting game*/=20
#include <stdio.h>=20
#include <stdlib.h>=20
#include <time.h>=20
int main()=20
{=20
int genre, level, answ, result, end, weight, tall, radius, prop, pula;=20
int vic, mvic, round, mov, mmov, posa, posb, posc, posd, pose, monster,
hit;=20
int agil, magil;=20
int a, u;=20
int difab, difup, difpta, difptb;=20
int strenght;=20
int abwer, upwer, piwer, mawer, cabwer, arwer;=20
int mabwer, mupwer, mpuiwer, mmawer, mcabwer, marwer;=20
int atpts, dfpts, agpts, witpts, velpts, dampts, sufpts, respts;=20
int matpts, mdfpts, magpts, mwitpts, mvelpts, mdampts, msufpts, mrespts;
int oat, odf, oag, owit, ovel, odam, ores;=20
char name[20];=20
char wear[16];=20
char clothab[16];=20
char clothup[16];=20
char abdo[] =3D "skirt";=20
char abcer[] =3D "skirt";=20
char abon[] =3D "pants";=20
char abtre[] =3D "leather pants";=20
char abfor[] =3D "leather skirt";=20
char abcin[] =3D "magic pants";=20
char abses[] =3D "magic skirt";=20
char absep[] =3D "armor pants";=20
char upcer[] =3D "body";=20
char upon[] =3D "shirt";=20
char updo[] =3D "jacket";=20
char uptre[] =3D "leather jacket";=20
char upfor[] =3D "armor plate";=20
char upcin[] =3D "leather armor";=20
char upsis[] =3D "armor";=20
char upsep[] =3D "magic armor";=20
srand(time(NULL));=20
strenght =3D 0;=20
while(strenght =3D=3D 0){ /*decides if there will be more fights
###first###*/=20
printf("Choose the character you want to control, first the genre, 0 for
female, 1 for male.\n");=20
scanf("%d", &genre);=20
printf(" And the name, no more of 19 letters.\n");=20
scanf("%s", name);=20
printf("Now choose the height,\n");=20
scanf("%d\n", &tall);=20
printf("and then choose the weight\n");//THESE TWO LINES CHANGE THE
ORDERING!!!!! =20
=20
The above style of comment is not ANSI C90 compliant.
=20
=20
=20
scanf("%d\n", &weight);=20
printf("choose the belt radius\n");=20
scanf("%d\n", &radius);=20
printf("Choose muscle/bone proportion\n");=20
scanf("%d\n", &prop);=20
printf ("your character is a ");=20
if (genre =3D=3D 0)=20
printf("female ");=20
else=20
printf ("male ");=20
/*if((prop >=3D 33) || (prop < 15)){ /*stablish a bone proportion if
the set by the player is unacceptable*/=20
=20
=20
Above you begin a comment and inside it another comment which ends at
the same line. The */ terminator terminates the first /*. So you think
you have commented all the block below while you did not!=20
=20
=20
prop =3D rand() % 5;=20
if(prop =3D=3D 0)=20
prop =3D 20;=20
else=20
if(prop =3D=3D 1)=20
prop =3D 23;=20
else=20
if(prop =3D=3D 2)=20
prop =3D 25;=20
else=20
if(prop =3D=3D 3)=20
prop =3D 28;=20
else=20
prop =3D 30;=20
} */ =20
=20
Nope, the above */ closes nothing and is a syntax error.
=20
=20
So here are the bugs i discovered witg a quick pass. Bad use of
comments, and REMOVE those \n and commas from scanf(). After you do the
above, resend the fixed code.
=20
=20
=20
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
<http://www.noicys.cjb.net/>=20
* Alternative URL: http://run.to/noicys
|
|
From: <Met...@ao...> - 2002-08-08 08:14:02
|
I got such the same problem, when I try to compile and run some of my window based projects, telling DevCpp to generate a console for debugging purposes. At this time, I must tell the linker to "include" some of libs to get my program running, otherwise I get "cannot link to..." linker errors. In the cas you are telling us, if you talk about "CreateBrushIndirect" API func, you must tell the compiler to link with gdi32.lib. Make sure you have the -lgdi32 command in the linker option edit control, in project options window. Send me a zip of your projects file, I might see what's happening and help you. Kind regards -- Seb |
|
From: Abhijit S. <mu...@gm...> - 2002-08-08 07:59:05
|
----- Original Message ----- From: "Daniel K. O." <dan...@ya...> To: "Dev-Cpp-Users" <dev...@li...> Sent: Thursday, August 08, 2002 5:04 AM Subject: Re: [Dev-C++] compiler psychiatrics > The control string in a scanf() call can be one of these 3 types: > - format specifier > - white space > - non white space > > When you use a control string like "%d,%d", scanf will read an int, read and > discard a comma, and read another int. > Same happens with your "%d\n" control string; it will read an int, then read > and discard a new-line caracter. > When scanf() can't find the non white space caracter, it normally finish, > and some caracters can remain in the keyboard buffer, so it will mess with > another scanf() calls if you don't use fflush(stdin) before them. > > > > (this is what I can remember, please someone correct me if I said something > incorrect :-) ) > Daniel K. O. Yes, scanf() is a very dirty function to use (because of the buffer mechanism)... it should be used only for the most quick-n-dirty programs. In more 'complete' programs, the safest thing to do would be to read into a buffer (using cin.getline() or gets()) and then parse it manually. So the compiler's fine, it's your code. Also, in the for(), while() thing that Carlos had written about, I'm pretty sure it was a syntax error or something. It happens very often, and when you read it for verification, you tend to miss it, because you're expecting something, say a semi-colon, and you come across a colon, and the eye's in-built error correction routines fix that :). There's the classic example of counting the number of 'F's in this sentence: FINISHED FILES ARE THE RESULT OF YEARS OF SCIENTIFIC STUDY COMBINED WITH THE EXPERIENCE OF YEARS Most people count three, but there are actually six (you tend to miss the 'OF's). A computer would count six perfectly. Proof that intelligence isn't exactly good? <shrug> The best thing to do when you have an error and you're sure it's in a line, but you can't find it, is re-type the whole line. Peace. ___________________________________________________________ Abhijit Shylanath E-mail: mu...@gm... || ibr...@bi... Web-site: http://mudeth.tripod.com/ |
|
From: Teodorescu C. <te...@xt...> - 2002-08-08 07:14:49
|
Zodiaq wrote: >Hello all Dev-C++ users and other hackers, > > Something very strange happened to me recently and then I've decided >to write small app to monitor how much data is being send and received >by my computer... I looked at MSDN, Platform SDK and some other sites >but couldn't find how to do what I want... this propably can't be >socket functions because these are only for creating and destroying >connections TCP and UDP... TAPI propably not because these are all >about Telophone lines... so where to start? How to monitor TCP/IP >trafic? Well for now I just want to get only butes send per second and >received per second... I don't want analize datagrams or something >like these... Any help? > Depends on what kind of monitoring to you want. The simple monitoring is no of packet send / recieve and this wou can do by click on open connection :-) in system tray. For more treffic control / monitor you need a firewall so to write a firewall is compicated and you need to read DDK form microsoft http://www.microsoft.com/ddk <http://www.microsoft.com/ddk> because you need to write a driver so isn't so easy afterall.You must write a driver below all protocols an up on netwoark card (modem whatever) so download a firewall eg zonealarm (serach on google i don't know the link) > >-_-_-_-_- >regards, Zodiaq... > > > >------------------------------------------------------- >This sf.net email is sponsored by:ThinkGeek >Welcome to geek heaven. >http://thinkgeek.com/sf >_______________________________________________ >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: Daniel K. O. <dan...@ya...> - 2002-08-07 23:34:32
|
Carlos García del Monte wrote:
>
> scanf("%d\n", &tall);
> printf("and then choose the weight\n");//THESE TWO LINES CHANGE THE
ORDERING!!!!!
> scanf("%d\n", &weight);
The control string in a scanf() call can be one of these 3 types:
- format specifier
- white space
- non white space
When you use a control string like "%d,%d", scanf will read an int, read and
discard a comma, and read another int.
Same happens with your "%d\n" control string; it will read an int, then read
and discard a new-line caracter.
When scanf() can't find the non white space caracter, it normally finish,
and some caracters can remain in the keyboard buffer, so it will mess with
another scanf() calls if you don't use fflush(stdin) before them.
(this is what I can remember, please someone correct me if I said something
incorrect :-) )
Daniel K. O.
_______________________________________________________________________
Yahoo! PageBuilder
O super editor para criação de sites: é grátis, fácil e rápido.
http://br.geocities.yahoo.com/v/pb.html
|
|
From: Carlos d. M. <cg...@wo...> - 2002-08-07 21:53:46
|
You're writting all in lowercase, but compiler (linker etc) is case sensitive, you shall write GetStockObject. And perhaps add some casts, for example, (HBRUSH)GetStockObject(WHITE_BRUSH).... philip rocker escribi=F3: > hi I'm puzzled. I've been making some simple Windows apps (running > Win95 on an old but otherwise reliable and virus -free machine). For > a while they compiled and ran OK but then they started coming up with > linker error messages - particularly inablity to find definitions > which should be in windows.h (actually in wingdi.h, I think) - such > as undefined 'getstockobject', 'createbrush', 'selectobject' etc. > I've tried reinstalling DevC which works for a while but the same > problem recurs and it's now pretty ineffective. Sometimes pasting the > original source code into empty projects also worked - but that's > tedious and it's also become ineffective. A few programs from the > 'Examples' folder still compile and link successfully. I'd be > grateful for any suggestions. ThanksPhilip |
|
From: <h.r...@gm...>
(by w. of <h.r...@gm...> - 2002-08-07 20:37:23
|
> h.r...@gm... wrote:
>
> > Hi list,
> >
> > sorry, i know its bad style to ask nearly the same question twice, but i
> > make no progress with this problem. All in this file works well, except
> the
> > getline command. Allways the program crashed at this point. No
> exception, no
> > message, nothing. Has anyone a idea ?
> > Thanks in advance !!
> >
> > greetings
> > Horst
> >
> > // File: readdata.cpp
> > // Last: 6.8.02
> >
> > #include "readdata.h"
> >
> > #ifndef PROCABI_H
> > #include "procabi.h"
> > #endif
> >
> > #ifndef DATEI_H
> > #include "datei.h"
> > #endif
> >
> > #ifndef INOUT_H
> > #include "inout.h"
> > #endif
> >
> > #include <cstdio>
> > #include <cstdlib>
> > #include <cmath>
> > #include <string>
> > #include <iostream>
> > #include <fstream>
> >
> > using std::cout;
> > using std::cerr;
> > using std::getline;
> >
> > extern TProzessfaehigkeit pf;
> > extern TRead read;
> >
> > //-------------------------------------------------------------------
> >
> > bool isLine2Skip(const string& s) {
> > return ( (s[0] == ';') || // Comment
> > (s[0] == ' ') || // Space
> > s.empty() ); // Empty String
> > } // bool isLine2Skip()
> >
> > int RdFile(const string& s) {
> > try {
> > ifstream in(s.c_str());
> > if (!in) throw ERR_FILE_OPEN;
> >
> > string line;
> >
> > do {
> > getline(in, line);
> > } while (isLine2Skip(line));
> > pf.MeanS = atof(line.c_str());
> >
> > do {
> > getline(in, line);
> > } while (isLine2Skip(line));
> > pf.UTG = atof(line.c_str());
> >
> > do {
> > getline(in, line);
> > } while (isLine2Skip(line));
> > pf.OTG = atof(line.c_str());
> >
> > while (getline(in, line)) {
> > if (!isLine2Skip(line)) pf.Add(atof(line.c_str()));
> > } // while
> > return 0;
> > } // try
> >
> > catch(...) {
> > cerr << " Fehler in Datei " << s << endl;
> > return 1;
> > } // catch
> > } // int RdFile()
> >
> Hi Horst!
> The order of the parameters in the function
> getline is a "string" and an "int" (e.g. getline(string, 50)).
> I'm not sure, but think you've used getline(int,string),
> since your getline is this way: getline(in, line), and "line"
> is a string, isn't?
>
> Regards,
> Rafael Charnovscki
>
yes, it is. line is a string. In an ifstream.
Some Book examples uses my kind of getline e.g.
B. Eckel "Thinking in C++" Vol. 1 or in Accelerated C++ p.131
regards
Horst
--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net
|
|
From: philip r. <ph...@ro...> - 2002-08-07 20:01:55
|
hi I'm puzzled. I've been making some simple Windows apps (running Win95 = on an old but otherwise reliable and virus -free machine). For a while = they compiled and ran OK but then they started coming up with linker = error messages - particularly inablity to find definitions which should = be in windows.h (actually in wingdi.h, I think) - such as undefined = 'getstockobject', 'createbrush', 'selectobject' etc. I've tried = reinstalling DevC which works for a while but the same problem recurs = and it's now pretty ineffective. Sometimes pasting the original source = code into empty projects also worked - but that's tedious and it's also = become ineffective. A few programs from the 'Examples' folder still = compile and link successfully. I'd be grateful for any suggestions. Thanks Philip |
|
From: Carlos d. M. <cg...@wo...> - 2002-08-07 19:18:39
|
Here is an avi showing the execution of the pogram form the message "compiler psychiatrics" |
|
From: Carlos d. M. <cg...@wo...> - 2002-08-07 18:48:34
|
Here is an old experiment for programming, when I still did not know
C++, (only a piece of the program, so I don't get you buried under a ton
of code). You run fine?
There are two lines, in red, that invert their order, the scanf is done
before its printf.
printf("and then choose the weight\n");//THESE TWO LINES CHANGE THE
ORDERING!!!!!
scanf("%d\n", &weight);
You see (adding two lines before)
___________________________________
| Title _0X |
|-----------------------------------------------|
| [...] |
| Choose the height. |
| 180 |
| _ |
|___________________________________|
The program asks for the height, you enter the height you want, 180, and
then you wait the next prompt for the weight, but you find there is the
cursor one line below, waiting your input...
___________________________________
| Title _0X |
|-----------------------------------------------|
| Choose the height. |
| 180 |
| 80 |
| And then choose the weight |
|___________________________________|
And you enter any number, then the prompt appears, and from now on all
inputs are before its prompt. When the moment arrives when the program
prints your character's statistics you see what went where. It continues
doing so till the end.
Copying the scanf after the printf and having two scanf only makes the
error repeat in the next pair printf/scanf
The best is that it happens when I compile it with borland 5.5.
/*a text-based fighting game*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int genre, level, answ, result, end, weight, tall, radius, prop, pula;
int vic, mvic, round, mov, mmov, posa, posb, posc, posd, pose, monster,
hit;
int agil, magil;
int a, u;
int difab, difup, difpta, difptb;
int strenght;
int abwer, upwer, piwer, mawer, cabwer, arwer;
int mabwer, mupwer, mpuiwer, mmawer, mcabwer, marwer;
int atpts, dfpts, agpts, witpts, velpts, dampts, sufpts, respts;
int matpts, mdfpts, magpts, mwitpts, mvelpts, mdampts, msufpts, mrespts;
int oat, odf, oag, owit, ovel, odam, ores;
char name[20];
char wear[16];
char clothab[16];
char clothup[16];
char abdo[] = "skirt";
char abcer[] = "skirt";
char abon[] = "pants";
char abtre[] = "leather pants";
char abfor[] = "leather skirt";
char abcin[] = "magic pants";
char abses[] = "magic skirt";
char absep[] = "armor pants";
char upcer[] = "body";
char upon[] = "shirt";
char updo[] = "jacket";
char uptre[] = "leather jacket";
char upfor[] = "armor plate";
char upcin[] = "leather armor";
char upsis[] = "armor";
char upsep[] = "magic armor";
srand(time(NULL));
strenght = 0;
while(strenght == 0){ /*decides if there will be more fights
###first###*/
printf("Choose the character you want to control, first the genre, 0 for
female, 1 for male.\n");
scanf("%d", &genre);
printf(" And the name, no more of 19 letters.\n");
scanf("%s", name);
printf("Now choose the height,\n");
scanf("%d\n", &tall);
printf("and then choose the weight\n");//THESE TWO LINES CHANGE THE
ORDERING!!!!!
scanf("%d\n", &weight);
printf("choose the belt radius\n");
scanf("%d\n", &radius);
printf("Choose muscle/bone proportion\n");
scanf("%d\n", &prop);
printf ("your character is a ");
if (genre == 0)
printf("female ");
else
printf ("male ");
/*if((prop >= 33) || (prop < 15)){ /*stablish a bone proportion if
the set by the player is unacceptable*/
prop = rand() % 5;
if(prop == 0)
prop = 20;
else
if(prop == 1)
prop = 23;
else
if(prop == 2)
prop = 25;
else
if(prop == 3)
prop = 28;
else
prop = 30;
} */ /*closes the stablishment of a
correct bone proportion*/
printf("called %s, of %d centimeters and %d kilogrames, with a
muscle-bone proprotion of %d, and belt radius of %d. So, your character
is ", name, tall, weight, prop, radius);
if ((prop <= 32) && (prop > 29))
printf("very strong ");
else
if ((prop <= 29) && (prop > 27))
printf("strong ");
else
if((prop <=27) && (prop > 22))
printf("normal in strenght ");
else
if((prop <= 22) && (prop > 14))
printf("weak ");
if(weight > (tall - 85)){
if(genre == 0)
printf("his/her size is only appearance ");
else
printf("his/her size is only appearance ");
}
else
if(prop <= 10){
printf("very weak ");
if(weight > (tall - 85))
printf("the mass is evidently uncompetent");
}
agil = (tall - weight + 100) - (radius / 2) + 70;
if(agil > 250)
printf("and very agile\n");
else
if((agil <= 250) && (agil > 235))
printf("and agile\n");
else
if((agil <= 235) && (agil > 215))
printf("and normal in agility\n");
else
if((agil <= 215) && (agil > 200))
printf("and slow\n");
else
if(agil <= 200)
printf("and completely lack of reflex\n");
printf("You can choose the next wearings:\n");
printf("Feet wearing: shoes, 1; boots, 2; long boots, 3; armor boots,
4.\n");
scanf("%d\n", &piwer);
printf("Legs wearing: pants, 1; skirt, 2; leather pants, 3; leather
skirt, 4; magic pants, 5; magic skirt, 6; armour pants, 7.\n");
scanf("%d\n", &abwer);
switch(abwer){
case 0:
strcpy(clothab, abcer);
break;
case 1:
strcpy(clothab, abon);
break;
case 2:
strcpy(clothab, abdo);
break;
case 3:
strcpy(clothab, abtre);
break;
case 4:
strcpy(clothab, abfor);
break;
case 5:
strcpy(clothab, abcin);
break;
case 6:
strcpy(clothab, abses);
break;
case 7:
strcpy(clothab, absep);
break;
}
printf("Body wearing: shirt, 1; jacket, 2; leather jacket, 3; armor
plate, 4; leather armor, 5; armor, 6; magic armor, 7.\n");
scanf("%d\n", &upwer);
switch(upwer){
case 0:
strcpy(clothup, upcer);
break;
case 1:
strcpy(clothup, upon);
break;
case 2:
strcpy(clothup, updo);
break;
case 3:
strcpy(clothup, uptre);
break;
case 4:
strcpy(clothup, upfor);
break;
case 5:
strcpy(clothup, upcin);
break;
case 6:
strcpy(clothup, upsis);
break;
case 7:
strcpy(clothup, upsep);
break;
}
printf("Head wearing: nothing, 1; hat, 2; helmet, 3;whole helm, 4.\n");
scanf("%d\n", &cabwer);
printf("Hand wearing: nothing, 1; glovers, 2; armor glovers, 3; armed
glovers, 4.\n");
scanf("%d\n", &mawer);
printf("weapon: none, 1; knife, 2; bar, 3; long bar,4; articulate bars,
5;bow, 6; long bow, 7; little axe, 8; big axe, 9; axe and net, 10; short
sword, 11; long sword, 12; sword and shield, 13;.\n");
scanf("%d", &arwer);
atpts = ((arwer + 1) * 30) + ((prop -15) * 40) + ((piwer + 1) * 50);
dfpts = ((agil) * 2) + ((abwer +1) * 15) + ((piwer +1) * 5) + ((cabwer
+1) * 150) + ((upwer +1) * 300) - (radius - 80);
if((arwer == 9) || (arwer == 10) || (arwer >= 12))
dfpts = dfpts + (arwer * 8);
else
dfpts = dfpts + (arwer * 3);
witpts = (rand() % 50) + 80;
velpts = (agil) * tall / weight;
dampts = (atpts / 2) + ((atpts * prop) / (agil));
respts = (((dfpts * velpts) / weight) + (atpts / witpts) + (agil * 10))
/ (weight / 4);
sufpts = (rand() % 10) + 2;
printf("attack points = %d\n defense points = %d\n wits points = %d\n
velocity points = %d\n damage points = %d\n resistence points = %d\n
suffering points = %d\n", atpts, dfpts, witpts, velpts, dampts, respts,
sufpts);
round = 0;
ores = respts;
ovel = velpts;
odam = dampts;
owit = witpts;
oat = atpts;
odf = dfpts;
a = abwer;
u = upwer;
difab = 0;
difup = 0;
difpta = (abwer * 15) / dfpts;
difptb = (upwer * 300) / dfpts;
printf("press 0 if you want to play again\n");
scanf("%d", &strenght);
} /*##first##*/
return 0;
}
P.S.- Sorry for my firsts shaming posts at this list, a year ago, more
or less, I regret having written so big stupidities, as I wrote those
couple of messages. Forgive me and forget them. (Yeah, I know, this line
should be in an older message, when the referenced messages were
remembered).
Thank you all
|
|
From: <h.r...@gm...> - 2002-08-07 18:13:07
|
Hi list,
sorry, i know its bad style to ask nearly the same question twice, but i
make no progress with this problem. All in this file works well, except the
getline command. Allways the program crashed at this point. No exception, no
message, nothing. Has anyone a idea ?
Thanks in advance !!
greetings
Horst
// File: readdata.cpp
// Last: 6.8.02
#include "readdata.h"
#ifndef PROCABI_H
#include "procabi.h"
#endif
#ifndef DATEI_H
#include "datei.h"
#endif
#ifndef INOUT_H
#include "inout.h"
#endif
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <iostream>
#include <fstream>
using std::cout;
using std::cerr;
using std::getline;
extern TProzessfaehigkeit pf;
extern TRead read;
//-------------------------------------------------------------------
bool isLine2Skip(const string& s) {
return ( (s[0] == ';') || // Comment
(s[0] == ' ') || // Space
s.empty() ); // Empty String
} // bool isLine2Skip()
int RdFile(const string& s) {
try {
ifstream in(s.c_str());
if (!in) throw ERR_FILE_OPEN;
string line;
do {
getline(in, line);
} while (isLine2Skip(line));
pf.MeanS = atof(line.c_str());
do {
getline(in, line);
} while (isLine2Skip(line));
pf.UTG = atof(line.c_str());
do {
getline(in, line);
} while (isLine2Skip(line));
pf.OTG = atof(line.c_str());
while (getline(in, line)) {
if (!isLine2Skip(line)) pf.Add(atof(line.c_str()));
} // while
return 0;
} // try
catch(...) {
cerr << " Fehler in Datei " << s << endl;
return 1;
} // catch
} // int RdFile()
--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net
|
|
From: Zodiaq <zo...@ac...> - 2002-08-07 17:56:14
|
Hello all Dev-C++ users and other hackers, Something very strange happened to me recently and then I've decided to write small app to monitor how much data is being send and received by my computer... I looked at MSDN, Platform SDK and some other sites but couldn't find how to do what I want... this propably can't be socket functions because these are only for creating and destroying connections TCP and UDP... TAPI propably not because these are all about Telophone lines... so where to start? How to monitor TCP/IP trafic? Well for now I just want to get only butes send per second and received per second... I don't want analize datagrams or something like these... Any help? -_-_-_-_- regards, Zodiaq... |
|
From: Ioannis V. <no...@ho...> - 2002-08-07 17:42:54
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Jim Watters > Sent: Wednesday, August 07, 2002 6:58 PM > To: dev...@li... > Subject: RE: [Dev-C++] Stupid question > > > > Thank you again. > > I have the 2nd edition of the book (1991) which does not cover > namespaces, Ahh, it's unfortunate but it is close to useless. C++ has become quite different since then. You have to get the 3rd or special edition... > but recently purchased "Beginning Visual C++ 6" by Ivor > Horton which is shaping up to be an excellent resource on both C++ and > general Windows programming. Give me a few months and I'll > not be such a > C++ newbie. (:) <= encapsulated Visual C++ 6 is very old and not ANSI C++ compliant... You should learn about VC++ 7 .NET (that's what i am also learning this time). From the series of those books, i have the "Beginning Visual Basic 6" which is useless too (VB 7 .NET is quite different than 6). Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |