title: C: No such file or directory
body: <p>when I hard code <code>chemin</code> in <code>open(chemin, O_RDONLY)</code> to a file name, the program works, but when I leave if to <code>open(chemin, O_RDONLY)</code> I get <code>No such file or directory</code>.</p>
  
  <p>Why isn't <code>chemin</code> in type_fichier used?</p>
  
  <p>When i use <code>printf("%s", chemin)</code> in <code>type_fichier</code> I get <code>'</code></p>
  
  <pre><code>int type_fichier(char * chemin) {
    int fp;
    if ((fp = open(chemin, O_RDONLY)) == -1) { perror(""); exit(0); }
  
    struct stat fileStat;
    if(fstat(fp, &amp;fileStat) &lt; 0)
      return 1;
  
    switch(fileStat.st_mode &amp; S_IFMT) {
      case S_IFBLK:  printf("block device\n");            break;
      case S_IFCHR:  printf("character device\n");        break;
      case S_IFDIR:  printf("directory\n");               break;
      case S_IFIFO:  printf("FIFO/pipe\n");               break;
      case S_IFLNK:  printf("symlink\n");                 break;
      case S_IFREG:  printf("regular file\n");            break;
      case S_IFSOCK: printf("socket\n");                  break;
      default:       printf("unknown?\n");                break;
    }
  }
  
  int main(int argc, char *argv[]) {
    char fn = "file";
    type_fichier(&amp;fn);
  }
  </code></pre>