If pExt is not NULL programm crashes.
It must be the call of strcmp.. I tested the snipped on VS2005 on my pc an it works.
Has anybody an idea where the problem is?
Thx
Hi,
I'm experiencing problems with the call of strrchr:
to find a file by its extension I use the following function:
<<code>>
struct dirent* GetNextFileByExtension(DIR *pDirectory, const char* cExtension)
{
struct dirent *pFile;
while ( (pFile = readdir(pDirectory)) != NULL )
{
char* pExt = NULL;
printf("%s \r\n", pFile->d_name);
pExt = strrchr(pFile->d_name, '.');
if(pExt != NULL)
{
printf("%s \r\n", pExt);
if(strcmp(pExt + 1, cExtension)==0)
return pFile;
}
}
return NULL;
}
<</code>>
If pExt is not NULL programm crashes.
It must be the call of strcmp.. I tested the snipped on VS2005 on my pc an it works.
Has anybody an idea where the problem is?
Thx
strrchr() wouldn't work on a non-terminated string so that's not it.
Stefan, do you see the extension printed? Also, I wonder maybe it's cExtension that is corrupted somehow. Try printing it too?
##strrchr()## wouldn't work on a non-terminated string so that's not it.
Stefan, do you see the extension printed? Also, I wonder maybe it's cExtension that is corrupted somehow. Try printing it too?
After updating all libraries it works now..
It seams as if this was the problem..
After updating all libraries it works now..
It seams as if this was the problem..
Important Information for this Arm website
This site uses cookies to store information on your computer.
By continuing to use our site, you consent to our cookies.
If you are not happy with the use of these cookies, please review our
Cookie Policy
to learn how they can be disabled.
By disabling cookies, some features of the site will not work.
Access Warning
You do not have the correct permissions to perform this operation.
Hi,
I'm experiencing problems with the call of strrchr:
to find a file by its extension I use the following function:
If pExt is not NULL programm crashes. It must be the call of strcmp.. I tested the snipped on VS2005 on my pc an it works. Has anybody an idea where the problem is?
Thx