dev-cpp-users Mailing List for Dev-C++ (Page 201)
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: <Luc...@wa...> - 2004-07-07 21:34:25
|
I installed Dev-C++ 4.9.8.10 on a new computer, then copied in a
directory on that PC my project with all source files (10 000 lines) and
the .dev file.
This project compiles OK on the old PC with Dev-C++
4.9.8.10, but on the new I can only get the message =93unable to run
program file=94 on Line 2 (whatever the file it is). I tried Rebuilding
all source files, or compiling file by file, but get only this message,
immediately after starting the compile. The only created files are
Project1_private.h and Projet1_private.rc. No .o or .exe are created.
I tried uninstalling and reinstalling Dev-C++, with no
success. So I can edit the files, but can=92t compile anything.
=20
In the =93Compile Log=94 window of Dev-C++:
Compiler: Default compiler
Building Makefile: "F:\Project\Makefile.win"
Executing make clean
Execution terminated
=20
=20
|
|
From: <or...@vp...> - 2004-07-07 18:39:37
|
Roland Zerek wrote: > Uz.ytkownik Bruce.J Sam napisa?: >=20 >=20 >> Thanks!But where can I download the binary release?I have only=20 >>found the source release in GNU's ftp,also in GOOGLE. >> >>*/OROSZI Bal=A8=A2zs <or...@vp...>/* wrote: >> >> Bruce.J Sam wrote: >> > I have download gdb6.1,but it has too many files in it.I don't >> > know how to replace the old gdb in Dev-C++'s directory,Please >> forgive my >> > poor experience.I only a beginner. >> >> I hope you downloaded the binary release, and not the source releas= e. >> Just copy gdb.exe, and other files from the same dir, to Dev-C++/bi= n or >> Dev-C++/mingw/bin or whereever your MinGW is. The easiest is to cop= y it, >> where gcc.exe is. >> >> -- >> Greetings, >> Bal=A8=A2zs >=20 >=20 > There is a gdb 6.0 at http://www.mingw.org/ Also note, that it's in the Snapshot section, near the bottom. -- Greetings, Bal=A8=A2zs |
|
From: Per W. <pw...@ia...> - 2004-07-07 14:58:49
|
Check out vesa graphics - a bios extension to control high-resolution graphics. I would actually recommend that you use the djgpp compiler instead of mingw. djgpp is also a gcc port, but building dos applications with dos-extender to support much memory and protected mode. Scan through the following links: http://www.google.se/search?q=vesa+graphics+programming&ie=UTF-8&hl=sv&meta= /Per W On Tue, 6 Jul 2004, Paul Ingelbrant wrote: > Quoting Marco Ribeiro <ma...@ne...>: > > > Hello all, > > > > > > > > I wish to know if is there a way to make a function in assembly, compile it > > in masm and then use it in c++. I search the web but found nothing about it. > > My idea is something like linking the masm result with my c++ program. > > > > Have you looked at http://www.masm32.com/ ? > > A would guess that masm produces a normal object file. Just declare the function > as extern C to avoid problem with name-mangling. > > Hmm... need to try it before saying too much... > > downloading masm32... > > (some sounds of your choice to illustrate work) > > Results: > > I tried this simple example: > > > .386 > .model flat,stdcall > option casemap:none > > include \masm32\include\windows.inc > > .code > asmfunc proc inp:UINT > mov eax, (inp) > add eax, 10 > > ret > > asmfunc endp > > end > > > linked the resulting .obj (project->project options, parameters add library or > object) with the following: > > #include <iostream> > #include <stdlib.h> > > extern "C" int asmfunc(int); > > > using namespace std; > > int main(int argc, char *argv[]) > { > > int x = 15; > x = asmfunc(x); > > cout << x << endl; > > system("PAUSE"); > return 0; > } > > > I do get a linker warning, but it does work. > > > So, I guess the answer is yes... > > > > > > > ------------------------------------------------------- > This SF.Net email sponsored by Black Hat Briefings & Training. > Attend Black Hat Briefings & Training, Las Vegas July 24-29 - > digital self defense, top technical experts, no vendor pitches, > unmatched networking opportunities. Visit www.blackhat.com > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Roland Z. <ro...@po...> - 2004-07-07 14:41:25
|
Uz.ytkownik Bruce.J Sam napisa?: > Thanks!But where can I download the binary release?I have only=20 > found the source release in GNU's ftp,also in GOOGLE. >=20 > */OROSZI Bal=A8=A2zs <or...@vp...>/* wrote: >=20 > Bruce.J Sam wrote: > > I have download gdb6.1,but it has too many files in it.I don't > > know how to replace the old gdb in Dev-C++'s directory,Please > forgive my > > poor experience.I only a beginner. >=20 > I hope you downloaded the binary release, and not the source releas= e. > Just copy gdb.exe, and other files from the same dir, to Dev-C++/bi= n or > Dev-C++/mingw/bin or whereever your MinGW is. The easiest is to cop= y it, > where gcc.exe is. >=20 > -- > Greetings, > Bal=A8=A2zs There is a gdb 6.0 at http://www.mingw.org/ --=20 Roland r o l a n d z (at) poczta fm |
|
From: Marco R. <ma...@ne...> - 2004-07-07 13:05:48
|
Hi, I wish to program graphics with assembler under c++. I know how to use opengl, but I want something different :-). I want to program myself the protocol with the videocard. My problem is that I can't use ms-dos int 10h interrupt because it won't work under windows. I search the web and found nothing about this :-(. Why can't I use int10h under windows? Can you point me some link where I can find stuff related to my problem? Thanks in advance. Marco |
|
From: Pascal <p.t...@ti...> - 2004-07-07 04:41:39
|
Hello All,
// ------------------------main.h----------------
#include <iostream>
#include <stdlib.h>
class A
{
public:
int f ();
};
int A::f(void)
{
return 5;
};
//----------------------------main.cpp---------------------------------------------
#include "main.h"
using namespace std;
int main(int argc, char *argv[])
{
A cA;
int *pFunc;
*pFunc = cA.f();
// cout << ??? How I can call cA.f() using the
pointer pFunc?
/* Direct Acces to the Function */
printf("printf - f() : %d \t |\t",cA.f());
cout << "COUT - f() : " << cA.f() << endl;
/* Acces with the pointeur *pFunc */
printf("printf - *pFunc : %x\ \t | \t",*pFunc);
cout << "COUT - *pFunc : " << *pFunc << endl;
/* Address of the pointeur *pFunc */
printf("printf - &pFunc : %x\ | \t",&pFunc);
cout << "COUT - &pFunc : " << &pFunc << endl;
system("PAUSE"); return 0;
}
Is that Right?
but how to acces to the Direct Adress of the function f()?
|
|
From: Brian D. <Bri...@ms...> - 2004-07-07 03:35:51
|
Is the TransparentBlt() function supported by the Dev-C++ compiler? I = added the lmsimg32.lib but the function was not recognized. Brian |
|
From: Brian D. <Bri...@ms...> - 2004-07-07 03:34:33
|
I want to build a dialog window but I'm getting a parse error in the =
following code from my resource file (the Style line is implicated). If =
anyone could help me locate the error I'd appreciate it greatly! =
thanks, Brian
PS. I get the same error with and without "DISCARDABLE"
//-----------------------------------------------------------------
//DIALOG BOX
//-----------------------------------------------------------------
IDD_HELP_ABOUT DIALOG DISCARDABLE 0, 0, 239, 66
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About The GAme"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "OK", IDOK, 174,18,50,14
PUSHBUTTON "Cancel", IDCANCEL, 170,40,50,15
GROUPBOX "Program Information", IDC_STATIC,7,7,225,52 =20
CTEXT "Program created by...", IDC_STATIC,15,20,150,35 =20
}
|
|
From: nuc p. <nuc...@ms...> - 2004-07-07 02:36:20
|
<html><div style='background-color:'><DIV class=RTE>
<P>per...you're very patient. thanx again. panos/peter<BR><BR></P></DIV>
<DIV></DIV>>From: Per Westermark <pw...@ia...>
<DIV></DIV>>To: PETER CAMPOS <pca...@cc...>
<DIV></DIV>>CC: dev...@li...
<DIV></DIV>>Subject: Re: [Dev-C++] die rolling problem
<DIV></DIV>>Date: Tue, 6 Jul 2004 22:57:46 +0200 (CEST)
<DIV></DIV>>
<DIV></DIV>>I don't know what you need face_1 ... face_6 for.
<DIV></DIV>>
<DIV></DIV>>int faces[6] is an array of 6 integers - same as the number of sides on a
<DIV></DIV>>dice. You start by setting each value to zero.
<DIV></DIV>>
<DIV></DIV>>Whenever you roll a dice, you get an asnwer between 1 and 6. If you get
<DIV></DIV>>the value 1, you increment faces[1-1]. If you get the dice value 2, you
<DIV></DIV>>increment faces[2-1] and so on.
<DIV></DIV>>
<DIV></DIV>>Let's assume that you do 100 rolls. When your for loop is finished, you
<DIV></DIV>>might write something like:
<DIV></DIV>> printf("Number of ones: %d.\n",faces[0]);
<DIV></DIV>> ...
<DIV></DIV>> printf("Number of sixes: is %d.\n",faces[5]);
<DIV></DIV>>
<DIV></DIV>>and get the output:
<DIV></DIV>> Number of ones: 17
<DIV></DIV>> ...
<DIV></DIV>> Number of sixes: 16
<DIV></DIV>>
<DIV></DIV>>There is no need for a second loop, other than at the end of the program
<DIV></DIV>>if you want to emit the percentage (or total count) you got of each of the
<DIV></DIV>>six sides of the dice. The same loop that throws the dice 'roll' number of
<DIV></DIV>>times will at the same time count the number of occurrences of the
<DIV></DIV>>different sides of the dice.
<DIV></DIV>>
<DIV></DIV>>/Per W
<DIV></DIV>>
<DIV></DIV>>On Tue, 6 Jul 2004, PETER CAMPOS wrote:
<DIV></DIV>>
<DIV></DIV>> > per, i follow your logic up until:
<DIV></DIV>> > "Maybe you somewhere in the program - in your first fir loop, where you
<DIV></DIV>> > >throw your dices - should use the first array and do:
<DIV></DIV>> > > faces[face-1]++;
<DIV></DIV>> > >to count up number on ones, twoes... while you are busy rolling the
<DIV></DIV>> > >dices."
<DIV></DIV>> >
<DIV></DIV>> > how would i implement the array into counting how many ties a number comes up while at the same time not incrementing the number of rolls? i understand that faces[0]=faces[1-1], for example but i don't know how to use it properly. i tried the do..while loop below but i know taht i am not using it properly.
<DIV></DIV>> > thanx peter
<DIV></DIV>> >
<DIV></DIV>> > #include <iostream>
<DIV></DIV>> > #include <ctime>
<DIV></DIV>> > #include <cstdlib>
<DIV></DIV>> > using namespace std;
<DIV></DIV>> > int main()
<DIV></DIV>> > {
<DIV></DIV>> > int faces[6] = {0};
<DIV></DIV>> > int face_1, face_2, face_3, face_4, face_5, face_6;
<DIV></DIV>> > face_1 = faces[0];
<DIV></DIV>> > face_2 = faces[1];
<DIV></DIV>> > face_3 = faces[2];
<DIV></DIV>> > face_4 = faces[3];
<DIV></DIV>> > face_5 = faces[4];
<DIV></DIV>> > face_6 = faces[5];
<DIV></DIV>> >
<DIV></DIV>> > int rolls;
<DIV></DIV>> > cout << "how many times do you want to roll the die? "; //how many times to roll die
<DIV></DIV>> > cin >> rolls;
<DIV></DIV>> >
<DIV></DIV>> > srand(time(0));
<DIV></DIV>> > int face;
<DIV></DIV>> > for(int i= 0; i < rolls; i++){
<DIV></DIV>> > do{
<DIV></DIV>> > face= rand();
<DIV></DIV>> > face= 1+ face%6;
<DIV></DIV>> > cout << "the die has rolled a:" << face << endl;
<DIV></DIV>> > }while (faces[face-1]++);
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> > }
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> > return 0;
<DIV></DIV>> >
<DIV></DIV>> > }
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> > ---------- Original Message ----------------------------------
<DIV></DIV>> > From: Per Westermark <pw...@ia...>
<DIV></DIV>> > Date: Tue, 6 Jul 2004 20:11:23 +0200 (CEST)
<DIV></DIV>> >
<DIV></DIV>> > >
<DIV></DIV>> > >
<DIV></DIV>> > >Let's see now:
<DIV></DIV>> > >
<DIV></DIV>> > >You have one array
<DIV></DIV>> > > int faces[6]
<DIV></DIV>> > >which you don't seem to use anywhere in your program - other than to
<DIV></DIV>> > >assign uninitialized variables (face_1) to index position 0:
<DIV></DIV>> > > int face_1;
<DIV></DIV>> > > faces[0] = face_1;
<DIV></DIV>> > >Maybe you wanted to write:
<DIV></DIV>> > > face_1 = faces[0];
<DIV></DIV>> > >since the goal should be that faces[0] stored the count of ones you got
<DIV></DIV>> > >from all the rolls?
<DIV></DIV>> > >
<DIV></DIV>> > >Then you have one other array
<DIV></DIV>> > > int die[6] = {1,2,3,4,5,6};
<DIV></DIV>> > >that is most definitely not needed.
<DIV></DIV>> > >
<DIV></DIV>> > >Maybe you somewhere in the program - in your first fir loop, where you
<DIV></DIV>> > >throw your dices - should use the first array and do:
<DIV></DIV>> > > faces[face-1]++;
<DIV></DIV>> > >to count up number on ones, twoes... while you are busy rolling the
<DIV></DIV>> > >dices.
<DIV></DIV>> > >
<DIV></DIV>> > >Aftwerards, faces[0] would be number of times you got a one. faces[1]
<DIV></DIV>> > >would be the number of times you got a two etc and faces[0] + faces[1] +
<DIV></DIV>> > >... + faces[5] would be the total number of times you rolled the dice,
<DIV></DIV>> > >i.e. the same as the value rolls. 100*faces[0] / rolls would then be
<DIV></DIV>> > >number of times you got a one.
<DIV></DIV>> > >
<DIV></DIV>> > >Since faces[0] .. faces[5] would then contain counted values, you never
<DIV></DIV>> > >need a second for loop in the program for building statistics. You could
<DIV></DIV>> > >however use the second loop to emit your 6 percentages: probability of
<DIV></DIV>> > >getting a one, probability of getting a two...
<DIV></DIV>> > >
<DIV></DIV>> > >I think I recommended you once before to always build your programs with
<DIV></DIV>> > >the setting -Wall active. That would have generated a warning about face_1
<DIV></DIV>> > >being used without having been initialized. Always let the compiler
<DIV></DIV>> > >generate as much warnings as possible. For a biginning programmer, all
<DIV></DIV>> > >warnings are useful. If you think a warning is stupid, you should know
<DIV></DIV>> > >specifically why the compiler emitted the warning, and why the warning
<DIV></DIV>> > >isn't apropriate for your specific program. When you are ready to keep a 5
<DIV></DIV>> > >minute presentation in front of your class about a specific warning, then
<DIV></DIV>> > >you have enough knowledge to decide when to ignore warnings of that
<DIV></DIV>> > >specific type. Before that, you should treat warnings as errors, and make
<DIV></DIV>> > >sure your code compiles with zero warnings at the highest warning level
<DIV></DIV>> > >(-Wall).
<DIV></DIV>> > >
<DIV></DIV>> > >/Per W
<DIV></DIV>> > >
<DIV></DIV>> > >On Tue, 6 Jul 2004, PETER CAMPOS wrote:
<DIV></DIV>> > >
<DIV></DIV>> > >> Remarks by per are below..i attempted to set up a counter to count the number of times a die comes up and from that calculate the percentage. so far i get very small negative numbers...
<DIV></DIV>> > >> am i going in the correct direction?
<DIV></DIV>> > >> panos/peter
<DIV></DIV>> > >>
<DIV></DIV>> > >> #include <iostream>
<DIV></DIV>> > >> #include <ctime>
<DIV></DIV>> > >> #include <cstdlib>
<DIV></DIV>> > >> using namespace std;
<DIV></DIV>> > >> int main()
<DIV></DIV>> > >> {
<DIV></DIV>> > >>
<DIV></DIV>> > >> int rolls;
<DIV></DIV>> > >> cout << "how many times do you want to roll the die? "; //how many times to roll die
<DIV></DIV>> > >> cin >> rolls; //user input
<DIV></DIV>> > >> int faces[6] = {0}; //array for storage of faces of die.
<DIV></DIV>> > >> //used later to calculate percentage
<DIV></DIV>> > >> int face;
<DIV></DIV>> > >> srand(time(0)); //user wants new random #'s generated each time
<DIV></DIV>> > >> int face_per;
<DIV></DIV>> > >>
<DIV></DIV>> > >> int die[6] = {1,2,3,4,5,6};
<DIV></DIV>> > >> for(int i = 0; i < rolls; i++){
<DIV></DIV>> > >> face = rand();
<DIV></DIV>> > >> face = 1+ face%6;
<DIV></DIV>> > >> cout << "the die has rolled: " << face << endl;
<DIV></DIV>> > >> }
<DIV></DIV>> > >>
<DIV></DIV>> > >> int face_1;
<DIV></DIV>> > >> int face_1_occur;
<DIV></DIV>> > >> faces[0] = face_1;
<DIV></DIV>> > >> face_1_occur = 0;
<DIV></DIV>> > >> for(int i =0; i<rolls; i++){
<DIV></DIV>> > >> face_1_occur = face_1 + 1; //counter for face 1
<DIV></DIV>> > >>
<DIV></DIV>> > >> double prob_1 = face_1_occur * 100/rolls;
<DIV></DIV>> > >> cout << "the probability to roll a 1 is" << prob_1 << endl;
<DIV></DIV>> > >> }
<DIV></DIV>> > >> return 0;
<DIV></DIV>> > >> }
<DIV></DIV>> > >>
<DIV></DIV>> > >> 1) You don't store an infinite number of dice values - no need to. Just
<DIV></DIV>> > >> emit the value for each throw on the fly. Then keep 6 counters - one for
<DIV></DIV>> > >> each of the 6 faces of the dice.
<DIV></DIV>> > >>
<DIV></DIV>> > >> 2) Emit the 6 counters. Percentage is just # of occurences * 100 / total
<DIV></DIV>> > >> throws.
<DIV></DIV>> > >>
<DIV></DIV>> > >> 3) If the values you put into an array are in range 1-6, of course the
<DIV></DIV>> > >> values stay in that range. However, normally when counting number of
<DIV></DIV>> > >> times you get a one, a two etc, you store that in an array with index 0 to
<DIV></DIV>> > >> 5, since all arrays in C and C++ starts with index zero.
<DIV></DIV>> > >>
<DIV></DIV>> > >> /Per W
<DIV></DIV>> > >
<DIV></DIV>> > >
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> > ______________ ______________ ______________ ______________
<DIV></DIV>> > ccny.cuny.edu
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> > -------------------------------------------------------
<DIV></DIV>> > This SF.Net email sponsored by Black Hat Briefings & Training.
<DIV></DIV>> > Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
<DIV></DIV>> > digital self defense, top technical experts, no vendor pitches,
<DIV></DIV>> > unmatched networking opportunities. Visit www.blackhat.com
<DIV></DIV>> > _______________________________________________
<DIV></DIV>> > Dev-cpp-users mailing list
<DIV></DIV>> > Dev...@li...
<DIV></DIV>> > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
<DIV></DIV>> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
<DIV></DIV>> >
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>-------------------------------------------------------
<DIV></DIV>>This SF.Net email sponsored by Black Hat Briefings & Training.
<DIV></DIV>>Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
<DIV></DIV>>digital self defense, top technical experts, no vendor pitches,
<DIV></DIV>>unmatched networking opportunities. Visit www.blackhat.com
<DIV></DIV>>_______________________________________________
<DIV></DIV>>Dev-cpp-users mailing list
<DIV></DIV>>Dev...@li...
<DIV></DIV>>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
<DIV></DIV>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
<DIV></DIV></div><br clear=all><hr> <a href="http://g.msn.com/8HMAENUS/2740??PS=47575">MSN Toolbar provides one-click access to Hotmail from any Web page FREE download!</a> </html>
|
|
From: <per...@ya...> - 2004-07-07 00:25:46
|
Thanks!But where can I download the binary release?I have only found the source release in GNU's ftp,also in GOOGLE. OROSZI Balázs <or...@vp...> wrote:Bruce.J Sam wrote: > I have download gdb6.1,but it has too many files in it.I don't > know how to replace the old gdb in Dev-C++'s directory,Please forgive my > poor experience.I only a beginner. I hope you downloaded the binary release, and not the source release. Just copy gdb.exe, and other files from the same dir, to Dev-C++/bin or Dev-C++/mingw/bin or whereever your MinGW is. The easiest is to copy it, where gcc.exe is. -- Greetings, Balázs --------------------------------- Do You Yahoo!? 100兆邮箱够不够用?雅虎电邮自助扩容! |
|
From: Per W. <pw...@ia...> - 2004-07-06 20:58:32
|
I don't know what you need face_1 ... face_6 for.
int faces[6] is an array of 6 integers - same as the number of sides on a
dice. You start by setting each value to zero.
Whenever you roll a dice, you get an asnwer between 1 and 6. If you get
the value 1, you increment faces[1-1]. If you get the dice value 2, you
increment faces[2-1] and so on.
Let's assume that you do 100 rolls. When your for loop is finished, you
might write something like:
printf("Number of ones: %d.\n",faces[0]);
...
printf("Number of sixes: is %d.\n",faces[5]);
and get the output:
Number of ones: 17
...
Number of sixes: 16
There is no need for a second loop, other than at the end of the program
if you want to emit the percentage (or total count) you got of each of the
six sides of the dice. The same loop that throws the dice 'roll' number of
times will at the same time count the number of occurrences of the
different sides of the dice.
/Per W
On Tue, 6 Jul 2004, PETER CAMPOS wrote:
> per, i follow your logic up until:
> "Maybe you somewhere in the program - in your first fir loop, where you
> >throw your dices - should use the first array and do:
> > faces[face-1]++;
> >to count up number on ones, twoes... while you are busy rolling the
> >dices."
>
> how would i implement the array into counting how many ties a number comes up while at the same time not incrementing the number of rolls? i understand that faces[0]=faces[1-1], for example but i don't know how to use it properly. i tried the do..while loop below but i know taht i am not using it properly.
> thanx peter
>
> #include <iostream>
> #include <ctime>
> #include <cstdlib>
> using namespace std;
> int main()
> {
> int faces[6] = {0};
> int face_1, face_2, face_3, face_4, face_5, face_6;
> face_1 = faces[0];
> face_2 = faces[1];
> face_3 = faces[2];
> face_4 = faces[3];
> face_5 = faces[4];
> face_6 = faces[5];
>
> int rolls;
> cout << "how many times do you want to roll the die? "; //how many times to roll die
> cin >> rolls;
>
> srand(time(0));
> int face;
> for(int i= 0; i < rolls; i++){
> do{
> face= rand();
> face= 1+ face%6;
> cout << "the die has rolled a:" << face << endl;
> }while (faces[face-1]++);
>
>
> }
>
>
>
> return 0;
>
> }
>
>
> ---------- Original Message ----------------------------------
> From: Per Westermark <pw...@ia...>
> Date: Tue, 6 Jul 2004 20:11:23 +0200 (CEST)
>
> >
> >
> >Let's see now:
> >
> >You have one array
> > int faces[6]
> >which you don't seem to use anywhere in your program - other than to
> >assign uninitialized variables (face_1) to index position 0:
> > int face_1;
> > faces[0] = face_1;
> >Maybe you wanted to write:
> > face_1 = faces[0];
> >since the goal should be that faces[0] stored the count of ones you got
> >from all the rolls?
> >
> >Then you have one other array
> > int die[6] = {1,2,3,4,5,6};
> >that is most definitely not needed.
> >
> >Maybe you somewhere in the program - in your first fir loop, where you
> >throw your dices - should use the first array and do:
> > faces[face-1]++;
> >to count up number on ones, twoes... while you are busy rolling the
> >dices.
> >
> >Aftwerards, faces[0] would be number of times you got a one. faces[1]
> >would be the number of times you got a two etc and faces[0] + faces[1] +
> >... + faces[5] would be the total number of times you rolled the dice,
> >i.e. the same as the value rolls. 100*faces[0] / rolls would then be
> >number of times you got a one.
> >
> >Since faces[0] .. faces[5] would then contain counted values, you never
> >need a second for loop in the program for building statistics. You could
> >however use the second loop to emit your 6 percentages: probability of
> >getting a one, probability of getting a two...
> >
> >I think I recommended you once before to always build your programs with
> >the setting -Wall active. That would have generated a warning about face_1
> >being used without having been initialized. Always let the compiler
> >generate as much warnings as possible. For a biginning programmer, all
> >warnings are useful. If you think a warning is stupid, you should know
> >specifically why the compiler emitted the warning, and why the warning
> >isn't apropriate for your specific program. When you are ready to keep a 5
> >minute presentation in front of your class about a specific warning, then
> >you have enough knowledge to decide when to ignore warnings of that
> >specific type. Before that, you should treat warnings as errors, and make
> >sure your code compiles with zero warnings at the highest warning level
> >(-Wall).
> >
> >/Per W
> >
> >On Tue, 6 Jul 2004, PETER CAMPOS wrote:
> >
> >> Remarks by per are below..i attempted to set up a counter to count the number of times a die comes up and from that calculate the percentage. so far i get very small negative numbers...
> >> am i going in the correct direction?
> >> panos/peter
> >>
> >> #include <iostream>
> >> #include <ctime>
> >> #include <cstdlib>
> >> using namespace std;
> >> int main()
> >> {
> >>
> >> int rolls;
> >> cout << "how many times do you want to roll the die? "; //how many times to roll die
> >> cin >> rolls; //user input
> >> int faces[6] = {0}; //array for storage of faces of die.
> >> //used later to calculate percentage
> >> int face;
> >> srand(time(0)); //user wants new random #'s generated each time
> >> int face_per;
> >>
> >> int die[6] = {1,2,3,4,5,6};
> >> for(int i = 0; i < rolls; i++){
> >> face = rand();
> >> face = 1+ face%6;
> >> cout << "the die has rolled: " << face << endl;
> >> }
> >>
> >> int face_1;
> >> int face_1_occur;
> >> faces[0] = face_1;
> >> face_1_occur = 0;
> >> for(int i =0; i<rolls; i++){
> >> face_1_occur = face_1 + 1; //counter for face 1
> >>
> >> double prob_1 = face_1_occur * 100/rolls;
> >> cout << "the probability to roll a 1 is" << prob_1 << endl;
> >> }
> >> return 0;
> >> }
> >>
> >> 1) You don't store an infinite number of dice values - no need to. Just
> >> emit the value for each throw on the fly. Then keep 6 counters - one for
> >> each of the 6 faces of the dice.
> >>
> >> 2) Emit the 6 counters. Percentage is just # of occurences * 100 / total
> >> throws.
> >>
> >> 3) If the values you put into an array are in range 1-6, of course the
> >> values stay in that range. However, normally when counting number of
> >> times you get a one, a two etc, you store that in an array with index 0 to
> >> 5, since all arrays in C and C++ starts with index zero.
> >>
> >> /Per W
> >
> >
>
>
>
> ______________ ______________ ______________ ______________
> ccny.cuny.edu
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by Black Hat Briefings & Training.
> Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
> digital self defense, top technical experts, no vendor pitches,
> unmatched networking opportunities. Visit www.blackhat.com
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: PETER C. <pca...@cc...> - 2004-07-06 20:28:33
|
per, i follow your logic up until:
"Maybe you somewhere in the program - in your first fir loop, where you
>throw your dices - should use the first array and do:
> faces[face-1]++;
>to count up number on ones, twoes... while you are busy rolling the
>dices."
how would i implement the array into counting how many ties a number comes up while at the same time not incrementing the number of rolls? i understand that faces[0]=faces[1-1], for example but i don't know how to use it properly. i tried the do..while loop below but i know taht i am not using it properly.
thanx peter
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
int faces[6] = {0};
int face_1, face_2, face_3, face_4, face_5, face_6;
face_1 = faces[0];
face_2 = faces[1];
face_3 = faces[2];
face_4 = faces[3];
face_5 = faces[4];
face_6 = faces[5];
int rolls;
cout << "how many times do you want to roll the die? "; //how many times to roll die
cin >> rolls;
srand(time(0));
int face;
for(int i= 0; i < rolls; i++){
do{
face= rand();
face= 1+ face%6;
cout << "the die has rolled a:" << face << endl;
}while (faces[face-1]++);
}
return 0;
}
---------- Original Message ----------------------------------
From: Per Westermark <pw...@ia...>
Date: Tue, 6 Jul 2004 20:11:23 +0200 (CEST)
>
>
>Let's see now:
>
>You have one array
> int faces[6]
>which you don't seem to use anywhere in your program - other than to
>assign uninitialized variables (face_1) to index position 0:
> int face_1;
> faces[0] = face_1;
>Maybe you wanted to write:
> face_1 = faces[0];
>since the goal should be that faces[0] stored the count of ones you got
>from all the rolls?
>
>Then you have one other array
> int die[6] = {1,2,3,4,5,6};
>that is most definitely not needed.
>
>Maybe you somewhere in the program - in your first fir loop, where you
>throw your dices - should use the first array and do:
> faces[face-1]++;
>to count up number on ones, twoes... while you are busy rolling the
>dices.
>
>Aftwerards, faces[0] would be number of times you got a one. faces[1]
>would be the number of times you got a two etc and faces[0] + faces[1] +
>... + faces[5] would be the total number of times you rolled the dice,
>i.e. the same as the value rolls. 100*faces[0] / rolls would then be
>number of times you got a one.
>
>Since faces[0] .. faces[5] would then contain counted values, you never
>need a second for loop in the program for building statistics. You could
>however use the second loop to emit your 6 percentages: probability of
>getting a one, probability of getting a two...
>
>I think I recommended you once before to always build your programs with
>the setting -Wall active. That would have generated a warning about face_1
>being used without having been initialized. Always let the compiler
>generate as much warnings as possible. For a biginning programmer, all
>warnings are useful. If you think a warning is stupid, you should know
>specifically why the compiler emitted the warning, and why the warning
>isn't apropriate for your specific program. When you are ready to keep a 5
>minute presentation in front of your class about a specific warning, then
>you have enough knowledge to decide when to ignore warnings of that
>specific type. Before that, you should treat warnings as errors, and make
>sure your code compiles with zero warnings at the highest warning level
>(-Wall).
>
>/Per W
>
>On Tue, 6 Jul 2004, PETER CAMPOS wrote:
>
>> Remarks by per are below..i attempted to set up a counter to count the number of times a die comes up and from that calculate the percentage. so far i get very small negative numbers...
>> am i going in the correct direction?
>> panos/peter
>>
>> #include <iostream>
>> #include <ctime>
>> #include <cstdlib>
>> using namespace std;
>> int main()
>> {
>>
>> int rolls;
>> cout << "how many times do you want to roll the die? "; //how many times to roll die
>> cin >> rolls; //user input
>> int faces[6] = {0}; //array for storage of faces of die.
>> //used later to calculate percentage
>> int face;
>> srand(time(0)); //user wants new random #'s generated each time
>> int face_per;
>>
>> int die[6] = {1,2,3,4,5,6};
>> for(int i = 0; i < rolls; i++){
>> face = rand();
>> face = 1+ face%6;
>> cout << "the die has rolled: " << face << endl;
>> }
>>
>> int face_1;
>> int face_1_occur;
>> faces[0] = face_1;
>> face_1_occur = 0;
>> for(int i =0; i<rolls; i++){
>> face_1_occur = face_1 + 1; //counter for face 1
>>
>> double prob_1 = face_1_occur * 100/rolls;
>> cout << "the probability to roll a 1 is" << prob_1 << endl;
>> }
>> return 0;
>> }
>>
>> 1) You don't store an infinite number of dice values - no need to. Just
>> emit the value for each throw on the fly. Then keep 6 counters - one for
>> each of the 6 faces of the dice.
>>
>> 2) Emit the 6 counters. Percentage is just # of occurences * 100 / total
>> throws.
>>
>> 3) If the values you put into an array are in range 1-6, of course the
>> values stay in that range. However, normally when counting number of
>> times you get a one, a two etc, you store that in an array with index 0 to
>> 5, since all arrays in C and C++ starts with index zero.
>>
>> /Per W
>
>
______________ ______________ ______________ ______________
ccny.cuny.edu
|
|
From: Alvin T. <al...@th...> - 2004-07-06 20:25:33
|
that's just jibba jabba.
laurent waro wrote:
> Salut à tous,
> quand j'essai d'afficher une donnée par l'intermédiare dun pointeur, ca
> marche pas... Type de programme : application DOS; déclenchement de
> l'erreur windows ("votre application a provoqué une erreur blablabla
> blablabla...) systématiquement à la ligne :
> int *lolo=10;
> printf("essai : %d",*lolo);
> le printf m'a l'air d'être correct, alors pourquoi quand je lance une
> compilation puis une execution sous DevC++, ca me provoque une plantage
> systématique de ma fenetre dos?
> Environnement : win XP
> NB : le même code sur une autre machine win XP avec une version de
> DevC++ plus ancienne ne fonctionne pas non plus... Sagit-il d'un
> problème lié à Win XP ou à un mode d'emploi de DevC++ ou de printf non
> compris?
>
> Merci les gars et bon code!
> Greats from Réunion Island....
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by Black Hat Briefings & Training.
> Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital
> self defense, top technical experts, no vendor pitches, unmatched
> networking opportunities. Visit www.blackhat.com
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
--
Alvin Thompson
Navy: 34
Army: 6
|
|
From: Paul I. <pi...@ot...> - 2004-07-06 19:56:31
|
Quoting Marco Ribeiro <ma...@ne...>: > Hello all, >=20 > =20 >=20 > I wish to know if is there a way to make a function in assembly, compil= e it > in masm and then use it in c++. I search the web but found nothing abou= t it. > My idea is something like linking the masm result with my c++ program. >=20 Have you looked at http://www.masm32.com/ ? A would guess that masm produces a normal object file. Just declare the f= unction as extern C to avoid problem with name-mangling. Hmm... need to try it before saying too much... downloading masm32... (some sounds of your choice to illustrate work) Results: I tried this simple example: .386 .model flat,stdcall option casemap:none include \masm32\include\windows.inc .code asmfunc proc inp:UINT mov eax, (inp) add eax, 10 ret asmfunc endp end linked the resulting .obj (project->project options, parameters add libra= ry or object) with the following: #include <iostream> #include <stdlib.h> extern "C" int asmfunc(int); using namespace std; int main(int argc, char *argv[]) { =20 int x =3D 15;=20 x =3D asmfunc(x);=09 =20 cout << x << endl; =20 system("PAUSE");=09 return 0; } I do get a linker warning, but it does work. So, I guess the answer is yes... |
|
From: Marco R. <ma...@ne...> - 2004-07-06 19:38:19
|
Hello all, I wish to know if is there a way to make a function in assembly, compile it in masm and then use it in c++. I search the web but found nothing about it. My idea is something like linking the masm result with my c++ program. Tanks in advance Marco. |
|
From: Guillermo G. <ggu...@ma...> - 2004-07-06 18:29:18
|
it would help if the email were in english. we don't all understand =
French.
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...]On Behalf Of laurent
waro
Sent: Tuesday, July 06, 2004 10:54 AM
To: dev...@li...
Subject: [Dev-C++] Win XP bug or not bug?
Salut =E0 tous,
quand j'essai d'afficher une donn=E9e par l'interm=E9diare dun pointeur, =
ca=20
marche pas... Type de programme : application DOS; d=E9clenchement de=20
l'erreur windows ("votre application a provoqu=E9 une erreur blablabla=20
blablabla...) syst=E9matiquement =E0 la ligne :
int *lolo=3D10;
printf("essai : %d",*lolo);
le printf m'a l'air d'=EAtre correct, alors pourquoi quand je lance une=20
compilation puis une execution sous DevC++, ca me provoque une plantage=20
syst=E9matique de ma fenetre dos?
Environnement : win XP
NB : le m=EAme code sur une autre machine win XP avec une version de=20
DevC++ plus ancienne ne fonctionne pas non plus... Sagit-il d'un=20
probl=E8me li=E9 =E0 Win XP ou =E0 un mode d'emploi de DevC++ ou de =
printf non=20
compris?
Merci les gars et bon code!
Greats from R=E9union Island....
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -=20
digital self defense, top technical experts, no vendor pitches,=20
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Per W. <pw...@ia...> - 2004-07-06 18:16:45
|
Sorry, my language skills aren't up to a non-english answer...
However:
Programmer bug: yes
XP bug: no
No good OS allows reading from an address the program doesn't own, in this
case address 10.
The following is ok, since the address of a is within the application
memory:
int a =3D 23;
int *lolo =3D &a;
printf("%d",*lolo);
Old 16-bit DOS compilers would have accepted code that played around with
the pointer. Not because it is valid code, but because MS-DOS can't detect
the error.
/Per W
On Tue, 6 Jul 2004, laurent waro wrote:
> Salut =E0 tous,
> quand j'essai d'afficher une donn=E9e par l'interm=E9diare dun pointeur, =
ca
> marche pas... Type de programme : application DOS; d=E9clenchement de
> l'erreur windows ("votre application a provoqu=E9 une erreur blablabla
> blablabla...) syst=E9matiquement =E0 la ligne :
> int *lolo=3D10;
> printf("essai : %d",*lolo);
> le printf m'a l'air d'=EAtre correct, alors pourquoi quand je lance une
> compilation puis une execution sous DevC++, ca me provoque une plantage
> syst=E9matique de ma fenetre dos?
> Environnement : win XP
> NB : le m=EAme code sur une autre machine win XP avec une version de
> DevC++ plus ancienne ne fonctionne pas non plus... Sagit-il d'un
> probl=E8me li=E9 =E0 Win XP ou =E0 un mode d'emploi de DevC++ ou de print=
f non
> compris?
>
> Merci les gars et bon code!
> Greats from R=E9union Island....
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by Black Hat Briefings & Training.
> Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
> digital self defense, top technical experts, no vendor pitches,
> unmatched networking opportunities. Visit www.blackhat.com
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Per W. <pw...@ia...> - 2004-07-06 18:12:18
|
Let's see now:
You have one array
int faces[6]
which you don't seem to use anywhere in your program - other than to
assign uninitialized variables (face_1) to index position 0:
int face_1;
faces[0] = face_1;
Maybe you wanted to write:
face_1 = faces[0];
since the goal should be that faces[0] stored the count of ones you got
from all the rolls?
Then you have one other array
int die[6] = {1,2,3,4,5,6};
that is most definitely not needed.
Maybe you somewhere in the program - in your first fir loop, where you
throw your dices - should use the first array and do:
faces[face-1]++;
to count up number on ones, twoes... while you are busy rolling the
dices.
Aftwerards, faces[0] would be number of times you got a one. faces[1]
would be the number of times you got a two etc and faces[0] + faces[1] +
... + faces[5] would be the total number of times you rolled the dice,
i.e. the same as the value rolls. 100*faces[0] / rolls would then be
number of times you got a one.
Since faces[0] .. faces[5] would then contain counted values, you never
need a second for loop in the program for building statistics. You could
however use the second loop to emit your 6 percentages: probability of
getting a one, probability of getting a two...
I think I recommended you once before to always build your programs with
the setting -Wall active. That would have generated a warning about face_1
being used without having been initialized. Always let the compiler
generate as much warnings as possible. For a biginning programmer, all
warnings are useful. If you think a warning is stupid, you should know
specifically why the compiler emitted the warning, and why the warning
isn't apropriate for your specific program. When you are ready to keep a 5
minute presentation in front of your class about a specific warning, then
you have enough knowledge to decide when to ignore warnings of that
specific type. Before that, you should treat warnings as errors, and make
sure your code compiles with zero warnings at the highest warning level
(-Wall).
/Per W
On Tue, 6 Jul 2004, PETER CAMPOS wrote:
> Remarks by per are below..i attempted to set up a counter to count the number of times a die comes up and from that calculate the percentage. so far i get very small negative numbers...
> am i going in the correct direction?
> panos/peter
>
> #include <iostream>
> #include <ctime>
> #include <cstdlib>
> using namespace std;
> int main()
> {
>
> int rolls;
> cout << "how many times do you want to roll the die? "; //how many times to roll die
> cin >> rolls; //user input
> int faces[6] = {0}; //array for storage of faces of die.
> //used later to calculate percentage
> int face;
> srand(time(0)); //user wants new random #'s generated each time
> int face_per;
>
> int die[6] = {1,2,3,4,5,6};
> for(int i = 0; i < rolls; i++){
> face = rand();
> face = 1+ face%6;
> cout << "the die has rolled: " << face << endl;
> }
>
> int face_1;
> int face_1_occur;
> faces[0] = face_1;
> face_1_occur = 0;
> for(int i =0; i<rolls; i++){
> face_1_occur = face_1 + 1; //counter for face 1
>
> double prob_1 = face_1_occur * 100/rolls;
> cout << "the probability to roll a 1 is" << prob_1 << endl;
> }
> return 0;
> }
>
> 1) You don't store an infinite number of dice values - no need to. Just
> emit the value for each throw on the fly. Then keep 6 counters - one for
> each of the 6 faces of the dice.
>
> 2) Emit the 6 counters. Percentage is just # of occurences * 100 / total
> throws.
>
> 3) If the values you put into an array are in range 1-6, of course the
> values stay in that range. However, normally when counting number of
> times you get a one, a two etc, you store that in an array with index 0 to
> 5, since all arrays in C and C++ starts with index zero.
>
> /Per W
|
|
From: laurent w. <lau...@ya...> - 2004-07-06 17:54:52
|
Salut à tous,
quand j'essai d'afficher une donnée par l'intermédiare dun pointeur, ca
marche pas... Type de programme : application DOS; déclenchement de
l'erreur windows ("votre application a provoqué une erreur blablabla
blablabla...) systématiquement à la ligne :
int *lolo=10;
printf("essai : %d",*lolo);
le printf m'a l'air d'être correct, alors pourquoi quand je lance une
compilation puis une execution sous DevC++, ca me provoque une plantage
systématique de ma fenetre dos?
Environnement : win XP
NB : le même code sur une autre machine win XP avec une version de
DevC++ plus ancienne ne fonctionne pas non plus... Sagit-il d'un
problème lié à Win XP ou à un mode d'emploi de DevC++ ou de printf non
compris?
Merci les gars et bon code!
Greats from Réunion Island....
|
|
From: PETER C. <pca...@cc...> - 2004-07-06 15:54:56
|
Remarks by per are below..i attempted to set up a counter to count the number of times a die comes up and from that calculate the percentage. so far i get very small negative numbers...
am i going in the correct direction?
panos/peter
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
int rolls;
cout << "how many times do you want to roll the die? "; //how many times to roll die
cin >> rolls; //user input
int faces[6] = {0}; //array for storage of faces of die.
//used later to calculate percentage
int face;
srand(time(0)); //user wants new random #'s generated each time
int face_per;
int die[6] = {1,2,3,4,5,6};
for(int i = 0; i < rolls; i++){
face = rand();
face = 1+ face%6;
cout << "the die has rolled: " << face << endl;
}
int face_1;
int face_1_occur;
faces[0] = face_1;
face_1_occur = 0;
for(int i =0; i<rolls; i++){
face_1_occur = face_1 + 1; //counter for face 1
double prob_1 = face_1_occur * 100/rolls;
cout << "the probability to roll a 1 is" << prob_1 << endl;
}
return 0;
}
1) You don't store an infinite number of dice values - no need to. Just
emit the value for each throw on the fly. Then keep 6 counters - one for
each of the 6 faces of the dice.
2) Emit the 6 counters. Percentage is just # of occurences * 100 / total
throws.
3) If the values you put into an array are in range 1-6, of course the
values stay in that range. However, normally when counting number of
times you get a one, a two etc, you store that in an array with index 0 to
5, since all arrays in C and C++ starts with index zero.
/Per W
______________ ______________ ______________ ______________
ccny.cuny.edu
|
|
From: Alvin T. <al...@th...> - 2004-07-06 15:24:03
|
if you're using c++ you may want to use virtual functions/polymorphism
instead of using function pointers...
-alvin
Harry Piterson wrote:
> Hello, All!!!
>
> I need to call function-member of class by its pointer. For example:
>
>
> //- main.h ----------------------------------
> #include <iostream>
> #include <stdlib.h>
>
> class A
> {
> public:
> int f (void) { return 5; }
> };
>
> //- main.cpp --------------------------------
> #include "main.h"
>
> using namespace std;
>
> int main(int argc, char *argv[])
> {
> A cA;
>
> int ( A::*pFunc ) (void);
>
> pFunc = &A::f;
>
> // cout << ??? How I can call cA.f() using the pointer pFunc?
>
> system("PAUSE");
> return 0;
> }
>
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by Black Hat Briefings & Training.
> Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
> digital self defense, top technical experts, no vendor pitches,
> unmatched networking opportunities. Visit www.blackhat.com
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
--
Alvin Thompson
Navy: 34
Army: 6
|
|
From: <and...@su...> - 2004-07-06 14:27:56
|
Dear Users,
-I need to develop an application in a Windows environment;
-This app has to use the USB port;
-I am at the beginning of the 5th. ed "Programming Windows" Charles
Petzold book;
-I am trying to still in a direct WinApi32 programming mode basis;
-I´m using Dev-cpp to develop the examples and some pieces of my app;
-This book is Windows 98/95 specific;
-My operating system is Windows XP;
-I´ve heard that there are restrictions to develop a device driver in
Windows XP and
Windows 2000;
My questions are:
-Can´t any person develop an application that uses a paralell port, an
USB port, etc
in the Windows XP and 2000?
-If I am interested to continue to develop in this way, must I have a
Windows 98?
Regards
Andre Barros
|
|
From: Per W. <pw...@ia...> - 2004-07-06 06:38:48
|
1) You don't store an infinite number of dice values - no need to. Just
emit the value for each throw on the fly. Then keep 6 counters - one for
each of the 6 faces of the dice.
2) Emit the 6 counters. Percentage is just # of occurences * 100 / total
throws.
3) If the values you put into an array are in range 1-6, of course the
values stay in that range. However, normally when counting number of
times you get a one, a two etc, you store that in an array with index 0 to
5, since all arrays in C and C++ starts with index zero.
/Per W
On Tue, 6 Jul 2004, PETER CAMPOS wrote:
> hi everyone, thanx for all of the help on the last program. im still pretty lost on what to do with it though. below i want to roll a die a number of times, user input, and output:
> the face which was rolled, the occurence for each face and the percentage for that face.
> i have a lot of questions:
>
> 1) how do i create an array to hold an infinite number of rolls? i.e. if the user wanted to roll the die 1 million or 1 billion times. so far i've made two arrays of 6.
> 2) how to output the occurences and based on that the percentage. do i use the array i created?
> 3) since i am using 1+r%6 to determine range, are the faces 1-6 in elements 1-6 or do they stay in 0-5?
>
> cpp is not my forte. im considering dropping my class. any suggestions based on the types of questions i've asked?
>
> thanx again..
> Peter/Panos
>
>
> #include <iostream>
> #include <ctime>
> #include <cstdlib>
> using namespace std;
> int main()
> {
>
> int rolls;
> cout << "how many times do you want to roll the die? "; //how many times to roll die
> cin >> rolls; //user input
> int faces[6] = {0}; //array for storage of faces of die.
> //used later to calculate percentage
> int face;
> srand(time(0)); //user wants new random #'s generated each time
> int face_per;
>
> int die[6] = {1,2,3,4,5,6};
> for(int i = 0; i < rolls; i++){
> face = rand();
> face = 1+ face%6;
> cout << "the die has rolled: " << face << endl;
> }
> return 0;
> }
>
>
>
> ______________ ______________ ______________ ______________
> ccny.cuny.edu
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by Black Hat Briefings & Training.
> Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
> digital self defense, top technical experts, no vendor pitches,
> unmatched networking opportunities. Visit www.blackhat.com
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: PETER C. <pca...@cc...> - 2004-07-06 04:22:17
|
hi everyone, thanx for all of the help on the last program. im still pretty lost on what to do with it though. below i want to roll a die a number of times, user input, and output:
the face which was rolled, the occurence for each face and the percentage for that face.
i have a lot of questions:
1) how do i create an array to hold an infinite number of rolls? i.e. if the user wanted to roll the die 1 million or 1 billion times. so far i've made two arrays of 6.
2) how to output the occurences and based on that the percentage. do i use the array i created?
3) since i am using 1+r%6 to determine range, are the faces 1-6 in elements 1-6 or do they stay in 0-5?
cpp is not my forte. im considering dropping my class. any suggestions based on the types of questions i've asked?
thanx again..
Peter/Panos
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
int rolls;
cout << "how many times do you want to roll the die? "; //how many times to roll die
cin >> rolls; //user input
int faces[6] = {0}; //array for storage of faces of die.
//used later to calculate percentage
int face;
srand(time(0)); //user wants new random #'s generated each time
int face_per;
int die[6] = {1,2,3,4,5,6};
for(int i = 0; i < rolls; i++){
face = rand();
face = 1+ face%6;
cout << "the die has rolled: " << face << endl;
}
return 0;
}
______________ ______________ ______________ ______________
ccny.cuny.edu
|
|
From: <jab...@ta...> - 2004-07-06 03:36:10
|
Hi, a) Does anybody know of a place where I can get toolbars to replace the standard MS toolbar.bmp? b) and where to get sample code and instructions to build a custom toolbar into a C++ program? Thanks for the tips. Jorge |