Author Topic: Help with file loader  (Read 3150 times)

Offline OctavariumXI

  • Single posting newcomer
  • *
  • Posts: 3
Help with file loader
« on: May 22, 2010, 04:28:33 am »
Aight, for the past week or so, I've been working on a custom-algorithm generated line-drawer, and just now I'm starting on a header file with the functions to load algorithms from a text file.

For some odd reason, whenever I use fscanf or fgetc, all it does is return a random integer or letter.

Here's the code;

Code
FILE *file = fopen( "used_alg.alg" , "r+" );
while ( a <= 3 ){
        test = fgetc(file);
        cout << xres[a] << endl;
        ++a;}

In which xres[] is an integer array of 4.

Any reason why it's not working? >_<

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Help with file loader
« Reply #1 on: May 22, 2010, 04:50:54 am »
Please ask this question to some C/C++ forum. Codeblocks forum doesn't discuss these kind of questions.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.