从结构的链表中打印字符串时,大小为1的读取无效

我已经创建了一个单链结构列表,并且试图从中打印一个字符串。我的链接列表定义为:

typedef struct LinkedListNode
{
    void* data;
    struct LinkedListNode* next;
} LinkedListNode;

typedef struct LinkedList
{
    int count;
    struct LinkedListNode* head;
} LinkedList;

我的结构定义为:

typedef struct
{
    char missile[10]; /* trying to print this */
    funcPtr missileFunc;
} missileStruct;

我的printf语句是这样的:

printf("Print this: %s\n",(*(missileStruct*)((*currentNode).data)).missile);

Valgrind输出:

==11680== Invalid read of size 1
==11680==    at 0x4E88CC0: vfprintf (vfprintf.c:1632)
==11680==    by 0x4E8F898: printf (printf.c:33)
==11680==    by 0x401F9E: game (game.c:53)
==11680==    by 0x401112: menu (menu.c:57)
==11680==    by 0x400A6F: main (main.c:13)
==11680==  Address 0xa656c676e6973 is not stack'd, malloc'd or (recently) free'd
==11680== 
==11680== 
==11680== Process terminating with default action of signal 11 (SIGSEGV)
==11680==  General Protection Fault
==11680==    at 0x4E88CC0: vfprintf (vfprintf.c:1632)
==11680==    by 0x4E8F898: printf (printf.c:33)
==11680==    by 0x401F9E: game (game.c:53)
==11680==    by 0x401112: menu (menu.c:57)
==11680==    by 0x400A6F: main (main.c:13)
Print this: ==11680== 
评论