TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Roy Mcneill
from: Frank Adam
date: 1996-10-12 05:57:04
subject: Auto string-length deter

G'Day Roy,
 
-=> Quoting Roy Mcneill to Paul Wankadia <=-
  
 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
 PW> program to program, so I have to account for that :)

 RM> Why? Let the user pass the string to you, find its length with
To save 2 bytes of course :)
But IMO it would be nice not having to worry about remembering the size of 
strings one wants to manipulate and letting functions take care of them.
This would make it very easy to use solely dynamic arrays.
Theoretically one could just set up a number of pointers,and just work 
on them without having a bunch of if(reallocs) everywhere. 
 
 RM> strlen(), and use alloc(), malloc(), new (in C++), or their
 RM> relatives, to allocate any memory whose size depends on this
 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.)
I don't think you understand what he wants to do, he wants to make a 
completely self efficient function, where the function will either resize 
or stop if the string passed to it is not big enough for the secific task.


  L8r Frank (fadam{at}ozemail.com.au).
  
___ Blue Wave/DOS v2.21

--- Gash
* Origin: The Software Parlour (3:635/544)
SEEN-BY: 50/99 620/243 623/630 632/349 635/503 544 727 711/409 410 413 430
SEEN-BY: 711/808 809 932 934 712/515 713/888 714/906 800/1
@PATH: 635/544 50/99 711/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™.