| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: c++ help |
From: "Geo"
"John Beckett" wrote in
message news:00d7r01cpta61tlkk763islqdfom4b3c4d{at}4ax.com...
> You should take the time to understand my earlier post because it
> contains standard C procedures that must be mastered.
I was more concerned with first getting something to actually compile, then
I can play with changing it and learning . I mean there is so much
stuff you guys are posting for me to learn that I have to take it in steps.
Especially since I'm just doing this 10 minutes at a time.
> I did not use
> itoa but instead performed the dirty trick of adding 48 to convert a
> digit to an ascii character.
Yes but then I don't learn how itoa works. First I wanted to understand
that then I'll go back and try the other ideas. I saved all the posts from
this thread.
> Paul was too polite to point out that my code is straight out of the
> Ark. His posts show proper procedures, but from your stated aims, you
> need to master the basic C skills, even if they are ugly.
There is another difference here too. I'm used to learning a programming
language out of order. By that I mean I usually learn a language by taking
apart programs, learning to read it before I learn to write it. So I tend
to pick up the most used techniques first, but in this case I'm taking a
class so I'm trying to learn in the order teached yet I still find myself
jumping 4 chapters ahead to pick up some simple function like itoa because
I need that for the simple program I'm playing around with. The program
examples in the book are just boooooooorrrrrrring..
> Another point, probably unimportant. You could extract the three
> digits that you want from one call to rand, as below:
> int n = rand();
> itoa((n%10),a,10);
> itoa(((n/10)%10),b,10);
> itoa(((n/100)%10),c,10);
See? Now that's the kind of stuff they never show you in a programming
book. Now I'm going to have to do a whole new program just to play around
with this and see exactly what it's doing so I can build my mental image.
That's really slick, it allows me to extract just one digit
out of a number so if n=4581 then c ends up being the 5. Very handy
technique, that was probably more useful than learning about itoa.
Geo.
--- BBBS/NT v4.01 Flag-5
* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45)SEEN-BY: 633/267 270 5030/786 @PATH: 379/45 1 396/45 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.