| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Auto string-length determination |
On 09 Oct 96, Roy McNeill wrote to Paul Wankadia -- PW> Oh. What if I use strdup() locally to create another string? RM> You can get the length of the current string anytime with strlen(), Yeah -- I figured that out later... Especially if initialised to ""... RM> and this will return the same value on the new string produced with RM> strdup(). Neither technique will tell you anything about the [100] Tho I wish it would! <:( RM> that was declared before your function was called - if you want RM> that figure, you'll have to pass that number as a parameter to the RM> function, or declare it globally somehow. As I've had drummed into me now :) Parameter time, I think... RM> Exactly why do you need the max length? Why can't you work with PW> Eh? I'm writing my own custom Get_Input() function and I'd like to PW> cut down the number of parameters that it takes -- especially the PW> one that passes the length of String... The length may vary from RM> Why? Let the user pass the string to you, find its length with RM> strlen(), and use alloc(), malloc(), new (in C++), or their RM> relatives, to allocate any memory whose size depends on this I'm assuming they've allocated memory already... RM> length. (Don't forget to dispose of this memory when you're RM> finished with it - use free() or delete or whatever. A polluted RM> heap can stuff up your program much later, and is a real bugger to RM> track down.) Righto then. Noted and thanks. 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 690/660 711/409 410 413 430 808 809 932 934 712/515 713/888 SEEN-BY: 714/906 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™.