我需要帮助解决这个问题。这是代码:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
struct Person{
char *name[100];
char *nationality[100];
};
void put_values(struct Person *p, const char *name){
strncpy(p->name, name, 500);
}
int main(int argc, char *argv[]){
struct Person *person = malloc(sizeof(struct Person));
put_values(person, argv[1]);
free(person);
return 0;
}
这是错误消息:
ex17t.c: In function ‘put_values’:
ex17t.c:19:3: warning: passing argument 1 of ‘strncpy’ from incompatible pointer type [enabled by default]
In file included from ex17t.c:4:0:
/usr/include/string.h:131:14: note: expected ‘char * __restrict__’ but argument is of type ‘char **’
任何帮助或提示将不胜感激。谢谢!