这段代码为何无法运行?
指针数组p所指向字符的值一个一个拷贝给指针q.以下代码对指针数组q也进行了初始化,这样子q算不算指向目标?
但却无法运行,是什么原因?代码如下:
程序代码:
#include <stdio.h> void strcpy1(char *q[], char *p[], int n) { int i; int j, m; for (i = 0; i<n; i++) for (m = 0; m<100 && *(p[i] + m); m++) *(q[i] + m) = *(p[i] + m); for (j = 0; j<n; j++) printf("%s ", q[j]); } int main(void) { char *p[5] = { "asdg", "uewnngn", "sngn", "fhh", "mngkkd" }; char *q[5] = {"qqqq","wwwwwww","eeee","iii","yyyyyy"}; strcpy1(q, p, 5); return 0; }