Hello folks,
I tried writing my own function on string copy and this is what i managed to do.Though it somehow works, I have got a great problem with the manipulation of pointers. Please explain or modify it for me. Thank You.
#include <stdio.h>
#include <stdlib.h>
int main()
{
char copy[30],original[30];
printf("Please enter a string\n");
scanf ("%s",original);
printf("Please enter a new string\n");
scanf ("%s",copy);
char* copyPtr;
char* originalPtr;
copyPtr = copy;
originalPtr = original;
printf ("You have entered\nOriginal = %s\nCopy = %s",original,copy);
// int i;
while (*originalPtr != '\0')
{
copyPtr = originalPtr;
originalPtr--;
}
originalPtr = original;
printf ("\n\nNow this is what we have\nOriginal = %s\nCopy = %s",originalPtr,copyPtr);
return 0;
}