I'm trying to write a simple edge detection program in c. I'm using Red Hat Enterprise Linux Server 7.7 (Maipo), and gcc version 4.8.5.
This is the start of the code:
#include <stdio.h>
#define size 200
int _tmain(int argc, _TCHAR* argv[])
{
char filein[size] = "./image.bmp";
FILE *fin;
fopen_s(&fin, filein, "rb");
return 0;
}
I initially, had a lot of problems with _TCHAR* so eventually I replaced it with just char, I have no idea if this will be a problem later, but at least it compiled and got rid of those errors. Now I'm getting the implicit declaration warning. I've tried to fix it by adding other #include's.
I've tried to fix it with:
#include <stdio.h>
#include <errno.h>
#include <string.h>
#define size 200
int main(int argc, char* argv[])
{
char filein[size] = "./image.bmp";
FILE *fin;
fopen_s(&fin, filein, "rb");
return 0;
}
But, I'm still getting the same warning, can someone tell me what I'm doing wrong?
Thanks.
Thank you so much, this works!
#include <stdio.h>
#define size 200
int main(int argc, char* argv[])
{
char filein[size] = "./image.bmp";
FILE *fin;
fin = fopen(filein, "rb");
return 0;
}
the
_sseries of functions are optional functions from Annex K of the C standard, and rarely does any C implementation bother to implement Annex K. The actual utility of the "safe" functions introduced in Annex K is much disputed; just ditch those functions and use the standard functions such asfopen.The only time I've ever come across the
_sfunctions have been in code written for Windows, and Microsoft includes their own versions of these functions that do not conform to the standard set forth in Annex K.See here for a study examining the utility of Annex K: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1967.htm
Their conclusion: