Thread: Trailing characters after strncpy

  1. #1
    Registered User
    Join Date
    Nov 2002

    Red face Trailing characters after strncpy

    Hi Guys,
    i have searched but could not find any previouse solution.
    I'm coping n characters, but after sending the final to the
    printer, i get some trailing characters like c@xn after the
    true result.

    when i send this to
    the result is mynam@cxn on the printer.
    Any help will do


  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Your code is incomplete. What is "name"? Without seeing your exact code, one can only speculate. I'm assuming name is a 4 byte array. As such, it's not null terminated, so your print statement displays until it hits a null (at some random point in memory).

    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Nov 2002


    Thanks guys for your reply, it has solved the problem

    Happy new year to u all

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. HELP!!!!emergency Problem~expert please help
    By unknowppl in forum C++ Programming
    Replies: 9
    Last Post: 08-21-2008, 06:41 PM
  3. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  4. How do you check how many characters a user has entered?
    By engstudent363 in forum C Programming
    Replies: 5
    Last Post: 04-08-2008, 06:05 AM
  5. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM