[HELP] Converting unsigned int to char*

Oct 4, 2011 at 12:53pm
Hi, i need your help, i need converting unsigned int into char*

I have code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//      Struct                     Struct            char*    + class:uint32
	ModelTextureDef* texdef = (ModelTextureDef*)(f.getBuffer() + header.ofsTextures);
	if(header.nTextures)
	{
		textures = new TextureID[header.nTextures];

		for(size_t i = 0; i < header.nTextures; i++)
		{
			char texname[256];

			char* nameOfs;
                        //        struct[size_t].uint32 here i need convert!
			nameOfs = texdef[i].nameOfs;
			
			if(texdef[i].type == 0)
			{
                                // I need it convert because here i need use it!!!
				strncpy(texname, f.getBuffer() + *nameOfs, texdef[i].nameLen);
				texname[texdef[i].nameLen] = 0;
				string path(texname);
				fixname(path);
				textures[i] = video.textures.add(texname);
			}
Oct 4, 2011 at 2:52pm
There is itoa() standard C function for this or std::stringstream class if you prefer C++ approach.
Oct 4, 2011 at 3:14pm
itoa() isn't standard.
Oct 4, 2011 at 3:21pm
Or boost::lexical_cast if you prefer a simple, clean and fast C++ approach.
Oct 4, 2011 at 3:34pm
How i can use stringstream or boost? I use itoa but isnt work
Oct 5, 2011 at 4:54am
Couldn't you use sprintf?
Oct 5, 2011 at 11:13am
1
2
3
4
5
			char* nameOfs;
			
			if(texdef[i].type == 0)
			{
				sprintf(nameOfs, "%u", texdef[i].nameOfs);


Don't working? Some tips?

And give me example or repair me when i have it wrong
Topic archived. No new replies allowed.