Warning

You're browsing the old v2.x documentation. This version is no longer maintained. Click here to go the v3.x documentation.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
strcpy [2019/05/22 21:46] neilsstrcpy [2019/05/22 21:51] (current) neils
Line 22: Line 22:
   10 a$="hello world"   10 a$="hello world"
   20 b$=right$(a$, 5)   20 b$=right$(a$, 5)
 +  30 print b$
      
 **XC=BASIC** code: **XC=BASIC** code:
Line 29: Line 30:
   b$ = @buffer!   b$ = @buffer!
   strcpy b$, a$+(strlen!(a$)-5)   strcpy b$, a$+(strlen!(a$)-5)
 +  print b$
 +  
 +Both programs will output "world".
      
 **Important note**: even if //source// is longer than //destination//, the routine will not stop copying at the end of //destination// which may lead to an overflow situation. You have to make sure that there is enough memory at the destination. **Important note**: even if //source// is longer than //destination//, the routine will not stop copying at the end of //destination// which may lead to an overflow situation. You have to make sure that there is enough memory at the destination.
  
 **Note**: you can't copy a string using ''$a=$b''. Refer to the [[strings|strings]] article to learn why. **Note**: you can't copy a string using ''$a=$b''. Refer to the [[strings|strings]] article to learn why.