From: Radical DOT NetSurfer AT delorie DOT com Newsgroups: comp.os.msdos.djgpp Subject: Re: printf vs stream IO Date: Sat, 29 Sep 2001 14:37:32 -0400 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <3BB60BE8 DOT 2C5B9EA7 AT worldnet DOT att DOT net> X-Newsreader: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: newsabuse AT supernews DOT com Lines: 73 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Sat, 29 Sep 2001 17:56:29 GMT, Les Cargill wrote: >Radical, NetSurfer wrote: >> > >> by programming around it, you will note that using the >> philosophy of GCC/GXX, it is necessary (right?) to >> make TWO SEPARATE ISOLATED CALLS to >> printf().... >> well, all I can say is... I wish someone would FIX IT! >> > >Why? It's not broken. This devolves to an argument about what "broken" >means, in this case. > >> ...and now we return you to your normally scheduled >> reality channel.... >> > >Perhaps 'C'/C++ is not for you... just a thought. FWIW, >*any* implementation that reverses the string >in place, written in Ada, Forth, assembly, Cobol >or Fortran would have exactly the same side effect. > >Now: > >void thing(char *inputstr) >{ > char temp[SIZE};// SIZE to be named later > assert(strlen(inputstr) < SIZE); > memcpy(temp,inputstr,strlen(inputstr)); > strrev(temp); > printf("original string = %s, reversed string = %s\n",inputstr,temp); >} What? Simple, ordinary strdup() was not good enough for you? >Any implementation in 'C' which hides context takes on a much more >sophisticated role than one that doesn't. The "simpler is better" >principle dictates that doing this is not necessarily good. If the >implementation allocates memory, the program now has to >dispose of it. If a static buffer is used, unless the application is >100% serialized about that object, unpredictable things will happen. > >C++ attemps to do something about this, at a cost in complexity and >raggedness of the context*. Java forces the use of garbage >collection, as do Lisp and other languages. > >*Not too bad in this case, but a slight generalization reveals that there is no >good general solution to the problem. > >It's a vale of tears. > >FWIW, Tcl would, interetsingly enough, work great in this instance. All >names are strings, and all values are strings, so the context can be completely >opaque. Kewl. Unfortunately, Tcl smudges scope, so there are the attendant >problems >with that, too. > >> email: radsmail AT juno DOT com >> http://members.tripod.com/~RadSurfer/ >> >> Join us on Yahoo at: >> http://groups.yahoo.com/group/BorlandCPPBuilder >> for informal discussions about all versions of C++Builder... >> [Computer programming for Windows 95, and Console32] >> (you must be a Yahoo member to join) char *strrev(const char *str) ; //use strdup !! da solution...at least.... SHEESH PEOPLE!