Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-23-2007, 10:27 AM   PM User | #1
JimJoyce
New to the CF scene

 
Join Date: Feb 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
JimJoyce is an unknown quantity at this point
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?
JimJoyce is offline   Reply With Quote
Old 05-23-2007, 05:04 PM   PM User | #2
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
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
oracleguy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:50 PM.


Advertisement
Log in to turn off these ads.