| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Auto string-length determination |
On 30 Sep 96, Paul Edwards wrote to Paul Wankadia -- PW> I tried to automatically determine the maximum string length by using : PW> int Max_Length = sizeof(String) / sizeof(char); PE> sizeof(char) is useless - it will ALWAYS be 1. Whoops... :) PW> because it is an array of char. What am I doing wrong? PE> Apart from that (it does no harm), what is actually wrong? I can't The int Max_Length = sizeof(String); is supposed to be in a function that is called and passed a char * to String, which (I am told) will then make Max_Length the sizeof() a char * !!! PE> see any reason why the above code wouldn't set Max_Length to 100. Of PE> course, the statement above needs to have String[100] in scope, not PE> char *String (which would return 2/4/etc). BFN. Paul. That is correct -- I am getting 2, not 100. How do I get the correct length with just a char * ??? Chow. Junyer Hakker. --- PPoint 2.00* Origin: Junyer's Workshop (3:640/772.3) SEEN-BY: 50/99 620/243 623/630 640/201 206 216 217 222 230 238 254 297 305 SEEN-BY: 640/309 370 375 386 531 535 547 739 750 772 773 820 821 822 823 890 SEEN-BY: 640/895 711/409 410 413 430 808 809 932 934 712/515 713/888 714/906 SEEN-BY: 800/1 @PATH: 640/772 531 201 820 711/409 808 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™.