誰能告訴我,以下聲明是正確與否:指向字符串的概念在C
char (*p)[10];
p
是一個指向10個字符的字符串。
我做了如下的程序:
/*PROGRAM*/
#include<stdio.h>
#include<string.h>
void xstrcpy(char (**)[], const char (**)[]);
void main()
{
const char (*xsource)[10]="SUPERB";
char (*xtarget)[10];
printf("\n\n*************PART1*************\n\n");
printf("%s\n",xsource);
printf("\n\n*************PART2*************\n\n");
xtarget=xsource;
printf("%s\n",xtarget);
printf("\n\n*************PART3*************\n\n");
xstrcpy(xtarget,xsource);
puts(xtarget);
}
void xstrcpy(char (**p)[],const char (**q)[])
{
p=q;
}
計劃的目的是將一個字符串從另一個複製。
在此先感謝。
http://cdecl.org的字符數組是你的朋友。 –