Salut tout le monde
Je suis à la recherche d'une fonction standard qui récupére le nom court d'un fichier depuis son chemin d'accès

Je sais que vous allez me dire de la coder par moi même !! En effet je l'ai codé et je l'ai testé en console et elle marche parfaitement !!
Voilà ma focntion :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
 
char shortName(const char chemin[], char nomCourt[]);
 
int main(int argc, char *argv[])
{
  int choix = 0, res, i;
  char tmp[1024], cheminFichier[1024] = "", nomCourtFichier[1024] = "";
 
  printf("Pour ouvrir la boite de dialogue de windows tapez 1 : ");
  scanf("%d", &choix);
  if (choix)
  {
    OPENFILENAME ofn;
    tmp[0] = '\0' ;
    ZeroMemory (&ofn , sizeof (OPENFILENAMEW));
    ofn.lStructSize = sizeof (OPENFILENAMEW);
    ofn.lpstrFile = tmp;
    ofn.nMaxFile = 1024;
    ofn.lpstrTitle = "Ouvrir un fichier audio";
    ofn.lpstrFilter = "Fichiers MP3 (*.mp3)\0*.mp3\0Fichiers MP2 (*.mp2)\0*.mp2\0Fichiers WAV (*.wav)\0*.wav\0Fichiers OGG (*.ogg)\0*.ogg\0Fichiers RAW (*.raw)\0*.raw\0Tous (*.*)\0*.*\0" ;
    ofn.Flags = OFN_LONGNAMES | OFN_EXPLORER;
    res = GetOpenFileName(&ofn);
    if (res != 0)
    {
      for (i = 0 ; i < 1024 ; i++)
        cheminFichier[i] = ofn.lpstrFile[i];
 
      shortName(cheminFichier, nomCourtFichier);
    }
  }
  printf("\nLe chemin d'acces du fichier est :\n");
  printf("%s\n\n", cheminFichier);
  printf("\nLe nom court du fichier est :\n");
  printf("%s\n\n", nomCourtFichier);
 
  system("PAUSE");
  return EXIT_SUCCESS;
}
 
char shortName(const char chemin[], char nomCourt[])
{
  int i, compteurAntiSlashs = 0, compteurVerification = 0, conservation = 0;
 
  for (i = 0 ; i < 1024 ; i++)
  {
    if (chemin[i] == '\\')
      compteurAntiSlashs++;
  }
  for (i = 0 ; i < 1024 ; i++)
  {
    if (chemin[i] == '\\')
    {
      compteurVerification++;
      if (compteurVerification == compteurAntiSlashs)
      {
        if (conservation == 0)
          conservation = i;
        nomCourt[i - conservation] = chemin[i + 1];
      }
    }
    else if (compteurVerification == compteurAntiSlashs)
    {
      nomCourt[i - conservation] = chemin[i + 1];
    }
  }
  return nomCourt;
}
Le problème c'est que si j'intégre cette fonction dans un grand code d'un programme en SDL, elle ne marche pas correctement : parfois elle renvoie le nom correct du fichier et parfois elle renvoie un nom incompréhensible et parfois un nom null !!
C'est très compilqué pour vous représenter ce problème !! Mais, en tous cas, ce n'est pas mon vrai problème maintenant, tout ce que je veux savoir : Y a-t il une fonction standard qui récupére le nom court d'un fichier depuis son chemin d'accès ??