I have to use the following C function in one of my programs (using Kiel compiler):
Prototype: int fopen (FILE* f, char* filename, char* mode)
Parameters:
1. f-Pointer to file structure
2. filename-Pointer to a memory location that contains the filename.
3. mode-Pointer to a memory location that contains the file open mode.
Return Value: 1, if file was opened successfully.
0, otherwise.
When I tried this I am getting error:
FILE * f;
char* filename;
char* mode;
int t;
filename[0]= 'g';
mode[0]='w';
t= fopen( f, filename[0],mode[0]);
Error:
COPYRIGHT Copyright (C) 2012 - 2013 ARM Ltd and ARM Germany GmbH. All rights reserved.
*** ERROR C141 IN LINE 171 OF F34x_MSD_F931DC_main.c: syntax error near 'FILE'
*** ERROR C202 IN LINE 171 OF F34x_MSD_F931DC_main.c: 'f': undefined identifier
*** ERROR C141 IN LINE 172 OF F34x_MSD_F931DC_main.c: syntax error near 'char'
*** ERROR C202 IN LINE 172 OF F34x_MSD_F931DC_main.c: 'filename': undefined identifier
*** ERROR C141 IN LINE 173 OF F34x_MSD_F931DC_main.c: syntax error near 'char'
*** ERROR C202 IN LINE 173 OF F34x_MSD_F931DC_main.c: 'mode': undefined identifier
*** ERROR C141 IN LINE 174 OF F34x_MSD_F931DC_main.c: syntax error near 'int'
*** ERROR C202 IN LINE 174 OF F34x_MSD_F931DC_main.c: 't': undefined identifier
*** ERROR C202 IN LINE 177 OF F34x_MSD_F931DC_main.c: 'filename': undefined identifier
*** ERROR C202 IN LINE 179 OF F34x_MSD_F931DC_main.c: 'mode': undefined identifier
*** ERROR C202 IN LINE 182 OF F34x_MSD_F931DC_main.c: 't': undefined identifier
C51 COMPILATION COMPLETE. 0 WARNING(S), 11 ERROR(S)
Can someone help me in correct usage ?
Update:
When I put the variable declarations at the beginning in the main I managed to remove all the errors. But a new error is coming now:
COPYRIGHT Copyright (C) 2012 - 2013 ARM Ltd and ARM Germany GmbH. All rights reserved.
*** ERROR C214 IN LINE 184 OF F34x_MSD_F931DC_main.c: illegal pointer conversion
I got some hint here, but even then unable to understand how to resolve this issue