| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | setmem and memset |
PF> MD> Where I was expecting 20... So I should have used sizeof(*myChar)!!!
PF>Nope. The sizeof(*myChar) == sizeof(char) == 1. This is
>what you should be doing, if you want to use "new":
PF> #define BUFSIZE 20 // or "const int BUFSIZE = 20;"
PF> char *myChar=new char[BUFSIZE];
> memset(myChar,0, BUFSIZE);
Then what's so great about allocating memory dynamically? I've just
recently started to do this, and this simply ruins the point. Again,
those ANSI guys should have thought this through. The sizeof() operator
should be "smart" and return the size of it regardless of how I created
it.
Michael Douglass
___
.Mike's Mail Internet: MICHAEL.DOUGLASS{at}LCHANCE.SAT.TX.US
--- Maximus/2 2.01wb
* Origin: The Rock BBS--410Meg, i486/33, ZyXEL v32bis. (1:387/31)SEEN-BY: 54/54 620/243 632/348 640/820 690/660 711/409 413 430 807 808 809 SEEN-BY: 711/934 712/353 623 713/888 800/1 2442/0 @PATH: 387/31 1102 3615/50 229/2 2442/0 711/409 54/54 711/808 809 934 |
|
| 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™.