| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Auto string-length deter |
On 02 Oct 96, Frank Adam wrote to Paul Wankadia -- PW> I tried to automatically determine the maximum string length by using PW> int Max_Length = sizeof(String) / sizeof(char); PW> because it is an array of char. What am I doing wrong? FA> If the string was declared locally yes it would work, but.. FA> The function only gets the pointer to the string, it has no idea about FA> the length of it, all it knows is that it'll have to put the strng it FA> gathers up in the function into the address provided. What would I have to do? Use strdup() to duplicate the string locally and then sizeof() that duplicate string perhaps??? FA> So sizeof() will return the length of the pointer. I seem to get 2... BTW how can I make a pointer to point to a set place in memory (i.e. segment and offset) ??? FA> Perhaps if the string is global it may also work, but i didn't try or FA> even said that !.:) What's wrong with global variables? :) FA> PS: if portability is not an issue look at heapwalk in Borland, or go What does heapwalk() do? (Forgive all these questions -- I only got myself a compiler earlier this year FA> 2 or 4 bytes (i forget) back from the pointer and you'll find the FA> alloced block size somewhere, it only seems to work with the Borland FA> RTL.. What's RTL? BTW I'd rather keep the code as portable as possible (between PC compilers anyway), so that's not an option really... 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™.