Re: String Comparision



On 29 Apr 2007 15:40:26 -0700, Old Wolf <oldwolf@xxxxxxxxxxxxxx>
wrote:

On Apr 30, 5:46 am, Flash Gordon <s...@xxxxxxxxxxxxxxxxxx> wrote:
Then your description of the problem is inaccurate, the code does not
modify the strings. I suggest you examine the improvements and comments
by myself and the others and see if it then works.

He never said it did. He said that "s" and "t" were modified.
Those are pointers to char, which he increments in each
loop iteration.


Yes he did. From the original message that started this thread

"On tracing the program i noticed that the strings "s" and "t" get
modified somehow in the comp function and as a result i am getting
incorrect results."

Notice "...the strings ... get modified...." In any event, it
probably means he was misinterpreting the output from his debugger.
When pointers s and t get modified (which we all agree is the actual
modification that occurs) to point past the terminating '\0'
characters, his debugger probably attempted to show him the "string"
at the new address. Since he was in the realm of undefined behavior
at this point, what the debugger showed was equally undefined and no
longer relevant to his question.


Remove del for email
.



Relevant Pages

  • Re: A taxonomy of types
    ... however, elsewhere in my project (off in the dynamic typesystem, ...), I ... (since I am using NULL-terminated strings), and so I have used U+10FFFF ... remember, C also has things like arrays, funtion pointers, nestable ... int RIL_TypeSmallIntP; ...
    (comp.lang.misc)
  • Re: new IL: C (sort of...).
    ... only for "recent" Pascals, ... far pointers weren't really limited, ... in my compiler, I made wchar_t a builtin type (in most cases, aliased to ... I could very well include builtin "managed strings" in the new IL. ...
    (comp.lang.misc)
  • Re: HeapFree() Failing to deallocate string
    ... I've been able to recreate and isolate the problem with HeapFree(), ... in this simplified example is just a pointer to 16 bytes to store pointers ... the szCaption strings need to be copied to the pointed to ... strings for which storage needs to be allocated, ...
    (microsoft.public.windowsce.embedded)
  • Re: Increasing efficiency in C
    ... >> The representation of a string in C is the sequence of characters, ... strings, they are passed the addresses of strings. ... supports pointers the way it does. ... Competent programmers make mistakes, too. ...
    (comp.lang.c)
  • Re: Whats the position of pointers
    ... The basics ARE simple and ... any teacher worth his salt can get it across with a debugger and an OHP ... Normally one is only interested in ones local implementation. ... Using a debugger in teaching pointers (for C; ...
    (comp.lang.c)

Loading