the task in this is to copy the first n characters from (null terminated) string2 (s2) into s1 while using pointers. I know how to copy the strings from one to another, but I am having issues with eliminating the extra values. For example:
s1= 'This is a test'
s2 = 'A test'
after copying, I am left with:
s1 = 'a tests a test'
Here is my code:
char *s1pointer;
const char *s2pointer;
int i;
int number_char_replace;
s1pointer = s1;
s2pointer = s2;
i=0;
number_char_replace = num;
for(i=0;s1pointer[i] !='\0'||s2pointer[i]!='\0';i++)
{
s1pointer[i]=s2pointer[i];
}
}
This is homework, so please dont feel the need to just give me the answer. A hint for the logic would be greatly appreciated. Thank you.