Hier wird die verknüpfte Liste und die Struktur:Arbeiten mit verknüpften Liste + struct C
#define MAX_PATH_SIZE (256)
#define MAX_NAME_SIZE (50)
struct Frame
{
char *name;
unsigned int duration;
char *path; // may change to FILE*
};
typedef struct Frame frame_t;
struct Link
{
frame_t *frame;
struct Link *next;
};
typedef struct Link link_t;
Und hier ist meine Funktion:
link_t* createFrame(char name[], int duration, char path[]){
frame_t * temp = (frame_t*)malloc(sizeof(frame_t));
temp->duration = duration;
strncpy(temp->name, name,MAX_NAME_SIZE);
strncpy(temp->path, path,MAX_PATH_SIZE);
link_t* newFrame = (link_t*)malloc(sizeof(link_t));
newFrame->frame = temp;
return newFrame;
}
Das Problem ist, dass die Funktion Stopp in der Linie arbeiten " strncpy (temp-> name) .. ", das komische daran ist, dass die temp-> duration funktioniert, aber nicht mit Strings. Fehler: "Nicht behandelte Ausnahme um 0x0F744645 (msvcr120d.dll)"
Mögliche Duplikat (https://stackoverflow.com/questions/5354933/strcpy-with-malloc) – jpw