Bonjour,
J'essaie de faire un programme en C++ avec Visual Studio 6 qui permet de convertir un char * en wchar *.
Voici le code : 
	
	| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 
 | #include <string>
#include <iostream>
void wsubstring(wchar_t *dest, const wchar_t *src, const int from, const int length)
{
      int i;
      for (i=0; i<length; i++)
         dest[i] = src[i+from];
      dest[i] = '\0';
}
 
void charToWchar(char *in, wchar_t *out)
{
   std::use_facet< std::ctype<wchar_t> >(std::locale()).widen(in,in+strlen(in),out);
   wsubstring(out, out, 0, strlen(in));
}
 
int main(void)
{
   char in[255] =  "coucou ca vas";
   wchar_t out[255];
   charToWchar(in, out);
   std::wcout << out << "\n";
   return 0;
} | 
 Seulement, j'obtient 2 erreurs pour la ligne 
	
	std::use_facet< std::ctype<wchar_t> >(std::locale()).widen(in,in+strlen(in),out);
   quand je compile :
	
	| 12
 3
 
 | error C2780: 'const _F &__cdecl std::use_facet(const class std::locale &,const _F *,bool)' : expects 3 arguments - 1 provided
 
error C2228: left of '.widen' must have class/struct/union type | 
 Je n'arrive pas à trouver la cause de ces erreurs. Merci pour votre aide.
						
					
Partager