0
pointer
#include <iostream> using namespace std; void cpy(char*, const char*); int main() { const char* s = "ABCDEFG"; char* ss = "ZZZZZZZZZZ"; cout << " s = [" << s << "], ss = [" << ss << "]\n"; cpy(ss,s); cout << " s = [" << s << "], ss = [" << ss << "]\n"; } void cpy(char* s1, const char* s2) { do *s1++ = *s2++; while (*s2); } not returning the copied version
9 ответов
+ 1
@Martin Thanks a lot
0
the question was
Write the following function that copies the first n bytes beginning with *s2 into the bytes
beginning with *s1, where n is the number of bytes that s2 has to be incremented before it
points to the null character '\0':
void cpy(char* s1,const char* s2)
0
@Martin That's for string but what if I want to do this using pointer? Like using this function..why it's not working
0
https://code.sololearn.com/c3A21A17A18A
the code runs but after calling the function the copied string do not show in the output,why is that?
and also another thing like really confuses me in pointer that is when to use a function like int* something and just int like what is the difference?
like for example between
int* addition() and int addition().
and the question no was 7.9