Archive for the ‘ c/c++ ’ Category

I've written a small C program, which would determine the maximum name length of directory and filename. I found out that there are different constants on different machines and OS.

Here's one for windows:

 
/* Language: C */
#include <stdio.h>
 
#include <unistd.h>
 
#include
<limits.h>
 
main(){
 
 printf("Maximum path size is %d\n", PATH_MAX);
 printf("File max is %d\n", FILENAME_MAX);
 
}
 

Here's a version on Linux:

 
/* Language: C */
#include <stdio.h>
 
#include <unistd.h>
 
#include
<limits.h>
 
main(){
 
 printf("Maximum path size is %d\n", PATH_MAX);
 printf("File max is %d\n", NAME_MAX);
 
}
 

Heres for the POSIX compliant OS

 
/* Language: C */
#include <stdio.h>
 
#include <unistd.h>
 
#include
<limits.h>
 
main(){
 
 printf("Maximum path size is %d\n",POSIX_PATH_MAX);
 printf("File max is %d\n", _POSIX_NAME_MAX);
 
}