yeah, try it this way.
The problem are these lines:
1 2
char *p = "Hello";
char *p2 = "Yes";
It's okey if you don't understand the reason:
in old c-code there was no keyword "const", today you would write
1 2
constchar *p = "Hello";
constchar *p2 = "Yes";
because you can't have a non-const pointer or lvalue-reference to an rvalue.
char* is treated different than other types so when compiling yours, this should give a warning because of deprecation. They can't take it out completely from C++ because it has to be backwards-compatible.
printf( "%s, p2"); // warning: too few arguments for format
char s[] = "Hello, student.";
printf( s ); // warning: format not a string literal and no format arguments
Yes, both cases do have something that is not quite what the printf() expects.
Note though that a warning is a mere warning, not an error. Your task, as one that knows the printf() and what your program should do, is to check the code and fix potential logical errors.
@pacman169
yeah, i know, that's why i said you should just make char s[]
if you really want to solve it with pointer you should make the 2nd parameter of the function a const char* (because you don't modify it) and you could dynamically allocate memory and then write "Hello" to p.
1 2 3 4 5 6
char *p = newchar[6]; // this one is modified
strcpy(p, "Hello"); // incluide <cstring>
constchar *p2 = "Yes"; // this one is not modified
void squeeze(char* s, constchar* p);