This is a discussion on Can't get fgets to work properly within the C Programming forums, part of the General Programming Boards category; Originally Posted by lonkz I tried initialising the stream in the main method just once before calling any functions and ...
Thank you tabstop. That seems to do the trick.
I never knew about the rewind function. Guess I didn't do my homework... for shame!
Anyways it works perfectly every time now and even a little faster with rewind(). Still kind of slow though, so I was wondering if there was anything to be done to increase the speed. I'm still not sure if a recursive function is the best way and there may be other things that can be improved significantly. The time it takes the program to execute grows ( not suprisingly ) eksponentially with longer strings. I am not sure if this is the correct place to ask this but any further help regarding optimization would be greatly appreciated.
You could read the file only once and store the dictioanary in an array.
checkDict() could operate on that array.
Great idea Kurt. I'm not totally down with two-dimensional arrays but I'll read up on it and give it a shot soon.
Edit: By the way Kurt, would some sort of hash set be preferrable to an array or would it even work and would it be faster than reading lines from a file stream?
I've been toying around with adding a couple of extra features and was wondering if it was possible to make some sort of indication that the application is running and not just stalled or waiting. Maybe something like an animation of three dots incrementing . . .
Another way could be the - \ | / - \ | - \ | /- thingie where a dash seems to be rotating.
I've been googling my fingers off but the answer seems to elude me.
Last edited by lonkz; 01-03-2009 at 01:53 PM.