Originally Posted by
Salem
Can you post a small and complete program which demonstrates the problem.
Your answer doesn't solve anything, it sweeps it under the carpet for it to reappear later on.
Well, this is not the complete program, just the faulty function:
Code:
int CFont::init(char *infoPath, char *infoFile)
{
char buffer[255];
char *strState;
char filename[255], filename2[255];
char dirName[255];
char nametemp[255];
char widthfile[255];
//int bogusVar;
FILE *fp; //buffer config file
//Path&filename config file
strcpy(filename,infoPath);
strcat(filename,"/");
strcat(filename,infoFile);
int scanBuff, tempW;
//open config file
if((fp=fopen(filename, "r")) == NULL)
{
printf("ERROR opening file %s\n\n", filename);
return -1;
}
//Reading configuration
strState = fgets (buffer, 255, fp);
//looping through comments (#)
while (buffer[0] == '#' || buffer[0] == '\r' || buffer[0] == '\0' || buffer[0] == '\n' || strlen(buffer) == 0)
{
strState = fgets (buffer, 255, fp);
}
scanBuff = sscanf ( buffer, "%s : %s : %s : %s : %d", nametemp, dirName, filename, widthfile, &mNumFonts);
strState = fgets (buffer, 255, fp);
//looping through comments (#)
while (buffer[0] == '#' || buffer[0] == '\r' || buffer[0] == '\0' || buffer[0] == '\n' || strlen(buffer) == 0)
{
strState = fgets (buffer, 255, fp);
}
scanBuff = sscanf ( buffer, "%d : %d : %d : %d : %d : %d : %d : %d", &mIndexLargeA, &mIndexSmallA, &mIndex0, &mIndexKoma, &mIndexDot, &mIndexDot2, &mIndexEq, &mIndexEs);
strState = fgets (buffer, 255, fp);
//looping through comments (#)
while (buffer[0] == '#' || buffer[0] == '\r' || buffer[0] == '\0' || buffer[0] == '\n' || strlen(buffer) == 0)
{
strState = fgets (buffer, 255, fp);
}
scanBuff=sscanf ( buffer,"%d : %d : %d : %d : %d",&mWidth, &mHeight, &mTransCol.transR, &mTransCol.transG , &mTransCol.transB);
//mWidth= tempW;
fclose(fp);
}
The class itself:
Code:
class CFont
{
public:
CPicFont* getPicFont(int no);
int getCharWidth(char nama);
string getName();
void draw(int xx, int yy, char huruf);
void createFont(char* folder, char* nama, SDL_Rect blit_Reg, char huruf);
CFont();
CFont(char *fontInfoPath, char *fontInfoFile, CSurface* screen);
int getHeight();
int getWidth();
virtual ~CFont();
private:
CSurface* mScreen;
int init(char *infoPath, char *infoFile);
int mNumFonts;
string mNamaFont;
TransparentColor mTransCol;
int mWidth;
int mHeight;
lstFontName mFontName;
lstFontHandle mFontHandle;
int mIndexLargeA;
int mIndexSmallA;
int mIndex0;
int mIndexKoma;
int mIndexDot;
int mIndexDot2;
int mIndexEq;
int mIndexEs;
};
The init function is called under the constructor.