Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1.  
  2. void pstrcpy(char *buf, int buf_size, const char *str)
  3. {
  4. int c;
  5. char *q = buf;
  6.  
  7. if (buf_size <= 0)
  8. return;
  9.  
  10. for(;;) {
  11. c = *str++;
  12. if (c == 0 || q >= buf + buf_size - 1)
  13. break;
  14. *q++ = c;
  15. }
  16. *q = '\0';
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement