What's wrong with the function fopen?
I used the function fopen to write a program under visualDSP++ environment and run it on ADSP21469.The program is very simple,as following:
/*****************************************************************************
* test.c
*****************************************************************************/
#define INPUT_FILE_NAME "H000a.wav"
#include <stdio.h>
int wavFileReadOpen(char *fileName)
{
FILE* fp = NULL;
if ((fp = fopen(fileName, "rb")) == NULL)
{
return -1;
}
return 0;
}
int main( void )
{
int open_flag = 0;
int test = 0;
if (wavFileReadOpen(INPUT_FILE_NAME) != 0)
{
open_flag = 0;
}
else
{
open_flag = 1;
}
test = 1;
return 0;
}
But no matter if file "H000a.wav" exists,function fopen always can't return NULL. What's wrong with it? Thank you!
what's wrong with the function fopen?
Hi,
Apologies for our delayed response.
The fopen function initializes the data structures that are required for reading or writing to a file. The file’s name is identified by filename, with the access type required specified by the string mode.
I can open file by using appropriate file name.I have modified the code by using filename as H000a.wav.
int wavFileReadOpen(char *fileName)
{
FILE* fp = NULL;
if ((fp = fopen(fileName, "rb")) == NULL)
{
return -1;
}
return 0;
}
For Example in the above code snippet ,I have modified the code snippet as below given code snippet. Can you please try the below given code and let us know how you get on.
Note : the H000a.wav should be placed into the directory of the your project.
int wavFileReadOpen(char *fileName)
{
FILE* fp = NULL;
fp = fopen("../H000a.wav", "rb");
if (fp == NULL)
{
return -1;
}
return 0;
}
Best Regards,
Kader
I'm sorry for my response so late.
The problem bothered me for a long time.I asked to others, but no one met the same problem as me.So I decided change another board to test.I used a ADSP21489 board to test the function fopen,then I succeed.Even though I don't the exact reason.
Hello,
Thanks for the information. We have also noted your feedback.
Let us know if you need any assistance in the future
Best Regards,
Kader
This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.
Thank you,
EZ Admin
Please log in to reply.