Increase number of files that can be opened
-
in windows, how do i set maximum open number of files ? i tried to set FOPEN_MAX in stdio.h file, but it's not working.... need help.... thanks in advance...
xyz
-
in windows, how do i set maximum open number of files ? i tried to set FOPEN_MAX in stdio.h file, but it's not working.... need help.... thanks in advance...
xyz
Why do you think you can set it?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
override the definition of FOPEN_MAX in your code not in stdio.h as #deinfe FOPEN_MAX //n is the value you need to set .
vineesh
Do you really think such a
#define
will be of any help? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
in windows, how do i set maximum open number of files ? i tried to set FOPEN_MAX in stdio.h file, but it's not working.... need help.... thanks in advance...
xyz
The limit will be in the actual library code - the constant in the header is just to let you know about the limit. You may be able to recompile your own version of the libraries with a higher max value, but there may be other factors causing the limitation. Or you could use API functions like CreateFile instead. The limit for that is "May as well be infinite. If you need to know the actual limit, you're in bigger trouble than you think". Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
-
Do you really think such a
#define
will be of any help? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]The actual definition of FOPEN_MAX in stdio.h is #define FOPEN_MAX 20 you can extend it to some limit (around 500) The below code works fine #include <stdio.h> #include <windows.h> #define FOPEN_MAX 500 FILE *stream, *stream2; int main( void ) { int numclosed; int fd =3; while (fd <= FOPEN_MAX) { if( (stream = fopen( "E:\\new.txt", "r" )) == NULL ) { printf( "The file was not opened\n [%d] ",GetLastError()); getchar(); } else { fd = fileno(stream); printf( "The file was opened and fd is [%d] \n " ,fd); } } numclosed = _fcloseall( ); printf( "Number of files closed by _fcloseall: %u\n", numclosed ); return 0; } ============
vineesh
-
The actual definition of FOPEN_MAX in stdio.h is #define FOPEN_MAX 20 you can extend it to some limit (around 500) The below code works fine #include <stdio.h> #include <windows.h> #define FOPEN_MAX 500 FILE *stream, *stream2; int main( void ) { int numclosed; int fd =3; while (fd <= FOPEN_MAX) { if( (stream = fopen( "E:\\new.txt", "r" )) == NULL ) { printf( "The file was not opened\n [%d] ",GetLastError()); getchar(); } else { fd = fileno(stream); printf( "The file was opened and fd is [%d] \n " ,fd); } } numclosed = _fcloseall( ); printf( "Number of files closed by _fcloseall: %u\n", numclosed ); return 0; } ============
vineesh
I don't get the point of doing that. Please see here [^] (as Iain explained very well the real purpose of
FOPEN_MAX
). :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I don't get the point of doing that. Please see here [^] (as Iain explained very well the real purpose of
FOPEN_MAX
). :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Yes Iain was correct ... The actual libary code restrict the number of file open to 510 (i dont know the exact value ..).But normally the system will not allow you to open more than 20 files from a process .This is because of the FOPEN_MAX set to 20 in the header stdio.h . #define FOPEN_MAX 20 We can only change the value below 510 . #define FOPEN_MAX 510 //upto this will work that means #define FOPEN_MAX 511 may not work as it trying to override the max limit in the actual libray code We cannot open infinite number of files using fopen ,but still we can extend the limit set in the stdio.h file as above . The usage of CreateFile is an absolute replacement for fopen if you need to open file more than 500 times from a single process.
vineesh
-
in windows, how do i set maximum open number of files ? i tried to set FOPEN_MAX in stdio.h file, but it's not working.... need help.... thanks in advance...
xyz