| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Pointers & Strings |
-=> Quoting Darin McBride to F. Tourigny <=-
DM> printf("pB is now at %p\n", (void*)pB);
DM> printf("Coincidentally, strB is also at %p\n", (void*)strB);
FT> while(*pA != '\0') /* line A (see text) */
FT> {
FT> *pB++ = *pA++; /* line B (see text) */
FT> }
DM> printf("After while loop, pB is at %p\n", (void*)pB);
DM> printf("This is a difference of %d\n", pB - strB);
DM> printf("Coincidentally, the string below's length is %d!\n\n",
DM> strlen(strB));
Those extra five lines helped me understand what's going on
behind the code. What's the (void*) for? Why use (void*)pB
instead of pB since both forms point to the same address?
Frederic
--- Blue Wave/DOS v2.30 [NR]
* Origin: Juxtaposition BBS. Lasalle, Quebec, Canada (1:167/133)SEEN-BY: 396/1 622/419 632/371 633/260 267 270 371 634/397 635/506 728 SEEN-BY: 639/252 670/213 218 @PATH: 167/133 320 166 396/1 633/260 635/506 728 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™.