View Single Post
  #4   Spotlight this post!  
Unread 28-02-2011, 23:18
masoug's Avatar
masoug masoug is offline
Food Consumer
FRC #0114
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Planet Earth
Posts: 78
masoug is an unknown quantity at this point
Re: help with file I/O on Crio ... unable to read file when fopen fails

Quote:
Originally Posted by byteit101 View Post
slightly off topic, but why are you using C style IO when C++ IO is available? In 09 we successfully used fstream IO with just "file.ext" style and "existingdir/file.ext" style open args
Code:
fstream file;
file.open("test.txt");


if (!file.is_open())
{printf("failed to open"); return false;}

file>>floatTest;


//and later we have something similar in order to write using fprintf
file<<floatTest;
Both ways are perfectly okay, depends on preference. We (114) like to use C-style I/O because it seems easier to use (for us).

Also, don't forget to call fclose or file.close() function before you exit.
__________________

JabbaScript
Reply With Quote