fork download
  1. #include<stdio.h>
  2.  
  3. int main(void)
  4. {
  5. char str1[8];
  6. char *p1=str1;
  7. char str2[8];
  8. char *p2=str2;
  9.  
  10. printf("Enter a string\n");
  11. do{
  12. scanf("%c",p1++);
  13. }while(*(p1 - 1) != '\n');
  14. *(p1 - 1) = '\0'; //placing terminating null character
  15.  
  16. p1 = &str1[0];
  17. while(*p1){
  18. *p2++ = *p1++;
  19. }
  20. *p2 = '\0'; //placing terminating null character
  21.  
  22. printf("The copied string is :");
  23. p2 = &str2[0];
  24.  
  25. while(*p2)
  26. printf("%c",*p2++);
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 2172KB
stdin
abcdef
stdout
Enter a string
The copied string is :abcdef