View Single Post
Old 13 January 2021, 23:15   #3
Registered User
thomas's Avatar
Join Date: Jan 2002
Location: Germany
Posts: 6,219
The C language does not know strings. You cannot assign strings using the = operator in C.

A STRPTR is a pointer to an array of characters. By assigning fileName to fib_FileName you let the pointer point to a part of the memory you allocated using AllocDosObjects before. Later you free that memory so that fileName now points to memory which is no longer valid.

What you have to do is

fl->fileName = malloc(strlen(fib->fib_FileName)+1);
strcpy (fl->fileName,fib->fib_FileName);
thomas is offline  
Page generated in 0.04377 seconds with 11 queries