Coding Nightmares and Coding Solutions!

For a long time a hitch in my program had been trying to get it to output my attention and meditation span into a text file.

These are read in from the mindwave device shown below.

20140320_144533

The problem was that I was trying to record the time with my results but in the text file where the results were stored I was recieving  this:

Attention Span:41 and the time is °ø

Attention Span:37 and the time is °ø

Attention Span:41 and the time is °ø A

ttention Span:43 and the time is XöR

and so on.

After a few hours thinking and dispairing over the issue at hand some research eventually yielded and answer. The ‘fprintf’ function I was using to print the notepad file is a very OLD function leftover from Visual C but still works in Visual C++. The problem is that the time I was passing to the function was in a string format, which is not a recognised format in Visual C (before it’s time if you like) and therefore it couldn’t understand the data it was told to display. This meant it instead pasted a random value. I then stumbled upon a better, newer funtion called fstream. This rapidly fixed the issue and left the way clear for further progress

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *