Thread: Curropted text

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,735
    Turns out memcpy does not do what is says on the tin, replaced it with this:
    Code:
    txt = (char*)(tok.dst.addr);
    for ( byte = 0; byte < size; ++byte, ++txt ) txt[byte] = cb[byte];
    and hay presto I have correct text, remind me never to expect common sense in the standard library

  2. #2
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    956
    Quote Originally Posted by awsdert View Post
    Turns out memcpy does not do what is says on the tin, replaced it with this:
    Code:
    txt = (char*)(tok.dst.addr);
    for ( byte = 0; byte < size; ++byte, ++txt ) txt[byte] = cb[byte];
    and hay presto I have correct text, remind me never to expect common sense in the standard library
    That's likely because you used memcpy in an undefined way (e.g., source and destination overlap). I haven't looked too deeply at your code to see if that's the case, but there's an exceedingly low chance (like one in a million) that a standard library function is at fault.

  3. #3
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,735
    Quote Originally Posted by christop View Post
    That's likely because you used memcpy in an undefined way (e.g., source and destination overlap). I haven't looked too deeply at your code to see if that's the case, but there's an exceedingly low chance (like one in a million) that a standard library function is at fault.
    Nope, that scenario is already ruled out by prior code, besides if that had been the issue then the loop I made would have encountered the exact same issue

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 02-16-2019, 07:47 PM
  2. User enter text and save to text file (end enter text using -1)
    By DecoratorFawn82 in forum C Programming
    Replies: 7
    Last Post: 12-28-2017, 04:23 PM
  3. Type text = Press button = Display text in Google?
    By Raze88 in forum C++ Programming
    Replies: 4
    Last Post: 03-20-2008, 08:39 AM
  4. Replies: 4
    Last Post: 01-03-2006, 03:02 AM
  5. create a text file with data using text editor
    By fried egg in forum C Programming
    Replies: 3
    Last Post: 03-14-2002, 09:11 PM

Tags for this Thread