Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. int main(int argc, char *argv[]) {
  2. char *x = "hello"; /* string 1 */
  3. char *y = "world"; /* string 2 */
  4. int n = 3; /* number of characters to copy */
  5.  
  6. for (int i=0; i<=n; i++) {
  7. if(i<n) {
  8. *x++ = *y++; /* equivalent of x[i] = y[i] ? */
  9. printf("%sn", x); /* just so I can see if something goes wrong */
  10. } else {
  11. *x++ = ''; /* to mark the end of the string */
  12. }
  13. }
  14. }
  15.  
  16. int main(int argc, char *argv[]) {
  17. char *s;
  18. char *t;
  19. int n; /* just initilaizing everything I need */
  20.  
  21. printf("Enter the string: ");
  22. scanf("%s", s); /* to scan in some phrase */
  23. printf("%s", s); /* to echo it back to me */
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement