in reply to Re: Re: C vs perl
in thread C vs perl

My comment was regarding the following statement:
szResult[3]='\0';
So, basically, you were putting '<', 'p', '>', '\0' at the beginning on the szResult. You need not put the null there.

Replies are listed 'Best First'.
null bytes (was Re: C vs perl)
by mandog (Curate) on Apr 29, 2002 at 02:19 UTC

    I'm probably missing something but...

    >man strcat
    [snip] DESCRIPTION The strcat() function appends a copy of the string pointed to by the s2 parameter (including the terminating null byte) to the end of the string pointed to by the s1 parameter. The initial byte of s2 overwrites the null byte at the end of the string pointed to by s1. When operating on overlapping strings, the behavior of this function is unreliable.

    How does strcat know where to append the second string w/o a null byte in string 1 ?



    email: mandog
      Sorry, my apologies. I was thinking of strcpy (as opposed to strcat) when I replied. You're absolutely correct.