格式'%s'需要'char *'类型的参数,但参数3在fprintf中的类型'int'[-Wformat]

时间:2012-11-30 09:59:41

标签: c types arguments printf

我有以下方法内容:

FILE *file;
file = fopen("customers.dat", "w");
PList *list;
list = &customers;
fprintf(file, "%s", *(list->person.name));
在fprintf行上给出

错误::

format '%s' expects argument of type 'char *', but argument 3 has type 'int' [-Wformat]

我有以下结构:

plist中:

typedef struct PList{
    Person person;
    struct PList *nextPerson;  //  set to NULL by default <<<<<
}PList;

人:

typedef struct Person{
    char name[100]; // Left as "" if empty Person
    PersonID ID;
    float amountOwed;
}Person;

是PersonID:

typedef struct PersonID{
    char letter;
    int number; // 7 digits
}PersonID;

1 个答案:

答案 0 :(得分:6)

放弃*

fprintf(file, "%s", *(list->person.name));
                    ^