Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    C programming: Terminating a String

    I feel such a fool.
    Until a few years ago I was a C Instructor.
    Now my C has become very rusty.

    If I strcpy part of a string into an empty buffer,
    how do I place a '\0' at the end of my new string?

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    strcpy should automatically terminate the new string.

    If you give it a null terminated string, it will copy the null along with the rest of the string into the buffer.
    OracleGuy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •