Re: K&R2, exercise 1-19




"arnuld" <geek.arnuld@xxxxxxxxx> wrote in message
news:1175838049.731644.266830@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Apr 6, 10:26 am, "user923005" <dcor...@xxxxxxxxx> wrote:


If you typed in 'hi' then arr will contain:
[h][i][0]

i think you meant: [h][i][\0]

followed by MAXLENGTH-3 garbage characters.

what does that mean ?

[garbage][h][i][\0] OR [h][i][\0][garbage]


The latter.


Also, you are supposed to reverse the string in place.

i am doing it but it is not working

Actually, you're not. In-place means only using additional storage of
constant size; you are using additional storage of size O(n).


Hint:
call strlen() to find out how big it is.

can't, K&R2 have not discussed "strlen()" yet.

Then you need to find it in some other way. Hint: the string ends with
'\0'...

--
Jonas


.



Relevant Pages

  • Re: curious about array initialization.
    ... understanding that its through the variable declaration that we ... By "inline string", I assume you mean a string literal. ... more than that you have implicit storage. ... Its a concept from computer programming. ...
    (comp.lang.c)
  • Re: curious about array initialization.
    ... understanding that its through the variable declaration that we ... By "inline string", I assume you mean a string literal. ... more than that you have implicit storage. ...
    (comp.lang.c)
  • Re: WORKING WITH STRINGS ?! THE FINAL CHALLENGE !
    ... the string should stay alive using the 'storage' pointer ... object Button1: TButton ...
    (alt.comp.lang.borland-delphi)
  • RE: XmlSerialization Object Memory Usage
    ... As you would expect, SimpleObject and ComplexObject are ... the same string objects. ... Hashtable storage = new Hashtable; ... private static ComplexObject BuildObject() ...
    (microsoft.public.dotnet.framework.performance)
  • Re: [Lit.] Buffer overruns
    ... >string convention which starts the operation and only discovers the ... >bound of an area by running into a specific data pattern in storage ... I generally use the bounded version of the string copy operation ...
    (sci.crypt)