Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: C vs perl

by mandog (Curate)
on Apr 29, 2002 at 01:14 UTC ( [id://162734]=note: print w/replies, xml ) Need Help??


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

Thanks for the corrections. --My C code is pretty ugly. Especially the \r\n vs \n\r thing .

For what it is worth I **do** need to allocate another byte for the terminating \0

strlen does **not** include the terminating null see man strlen



email: mandog

Replies are listed 'Best First'.
Re: Re: Re: C vs perl
by abstracts (Hermit) on Apr 29, 2002 at 01:52 UTC
    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.

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://162734]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found