Error using sscanf

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Error using sscanf

Post by Ghoti »

Hi folks,

I get this err when trying to use sscanf:

Code: Select all

warning: format '%f' expects type 'float *', but argument 3 has type 'double'
with this code:

Code: Select all

sscanf((ReadBuffer+2), "%f%f%f",tmpObj->m_Vertices[ vc ].x, tmpObj->m_Vertices[ vc ].y, tmpObj->m_Vertices[ vc ].z);
the wierd thing is that the m_Vertices is a float however for somereason it is not taken that way. Why is that?

here the code i use to create the tmpObj:

Code: Select all

typedef struct { float x, y, z; } ObjVertex;	// the vertex
	typedef struct { float x, y, z;	} ObjNormal;	// the normal
	typedef struct { float u, v;	} ObjTexCoord;	// texture coordinates
	typedef struct {
		unsigned int	*m_aVertexIndices,
						*m_aNormalIndices,
						*m_aTexCoordIndices;
		unsigned int	 m_iVertexCount;
	} ObjFace;										// face

	
	typedef struct _Mesh {
		unsigned int	iNumberOfGroups;
		ObjVertex		*m_Vertices;
		ObjNormal		*m_Normals;
		ObjTexCoord		*m_TexCoords;
		ObjFace			*m_Faces;
		unsigned int	*iSplit;
		unsigned int	 m_iNumberOfVertices,
						 m_iNumberOfNormals,
						 m_iNumberOfTexCoords,
						 m_iNumberOfFaces;
	} Mesh;
The tmpObj is a struct Mesh

any ideas?
Aion
Posts: 40
Joined: Mon Jul 24, 2006 10:58 pm
Location: Montreal

Post by Aion »

You're passing the float value, not the adress of the variable.

Try this : &tmpObj->m_Vertices[ vc ].x instead.
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Post by Ghoti »

thanks it worked like a charm.
Post Reply