我想更改constant-character-array
( const array[64]
) 的内容。
下面是我的代码。
我的问题const char *append
是,当作为常量字符指针( )传递给函数时,为什么常量字符数组不改变(不反映回来)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int function(char *d,const char *append)
{
append = d; //changing the location of append.
printf ("%s\n",append); //displays as sachintendulkar.
}
int main()
{
char *d = NULL;
const char append[]={'s','a','c','h','i','n'};
d = calloc(sizeof(char),sizeof(append));
strcpy(d,append);
strcat(d,"tendulkar"); //appending
function(d,append);
printf ("%s\n",append); //Its displays as sachin instead of sachintendulkar???
}