Thanks for help Prelude.
I didn't know that const char *str is the same as char const *str.
The use of const for guarding against modification of pointer works fine. It hinders pointer modification.
However, how can I make the object pointed to read-only?
Code:
#include <stdio.h>
#include <string.h>
void fun (const char *input);
int main (void)
{
char input [10] = "Hey";
printf ("%s\n", input);
fun (input);
printf ("%s\n", input);
return 0;
}
void fun (const char *input)
{
char *input2 = "Bye";
strcpy (input, input2);
return;
}
The object pointed to by input keeps getting modified by fun()