Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

convert TCHAR * to char *

3 Février 2013 Publié dans #c-c++

Windows Data Types for Strings (Windows) :

int wstrlen(_TCHAR * wstr)

{

int l_idx = 0;

while (((char*)wstr)[l_idx] != 0) l_idx += 2;

return l_idx;

}

char *wstrdup(_TCHAR *wSrc)

{

int l_idx = 0;

int l_len = wstrlen(wSrc);

char *l_nstr = (char *)malloc(l_len);

if (l_nstr) {

do {

l_nstr[l_idx] = (char)wSrc[l_idx];

l_idx++;

} while ((char)wSrc[l_idx] != 0);

}

l_nstr[l_idx] = 0;

return l_nstr;

}

Publicité
Partager cet article
Repost0
Pour être informé des derniers articles, inscrivez vous :
Commenter cet article