Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!decwrl!ucbvax!hplabs!hp-pcd!hpmcaa!nacer From: nacer@hpmcaa.mcm.hp.com (Abdenacer Moussaoui) Newsgroups: comp.lang.c Subject: left( source, count ) in C Message-ID: <510007@hpmcaa.mcm.hp.com> Date: 16 Mar 90 17:55:54 GMT Organization: HP McMinville Division Lines: 23 How do you write a function that returns the left part of a string in C? The interface is left( source, count ) here are some test cases: left( "123456789", 3 ) returns "123" left( "123456789", 20 ) returns "123456789" if stimef( current_time ) returns "13:45:23:48" then left( stimef( current_time ), 8 ) returns "13:45:23" As you can see in the last case, I would't want left(,) to modify the source (ie. implementing left something like source[count] = '\0' ) If this definition of left() does not fit "standard" C assumptions about strings, what how would you code left if source was restricted to type SMALL_STRINGS defined as typedef char SMALL_STRINGS[500] instead of just the (char *)? Thanks for any info. Thank you. --Abdenacer (nacer@hpmcaa.mcm.hp.COM)