View Single Post
  #10   Spotlight this post!  
Unread 01-10-2010, 07:47 PM
karatekid's Avatar
karatekid karatekid is offline
Registered User
AKA: Cole
FRC #0662 (Rocky Mountain Robotics)
Team Role: Programmer
 
Join Date: Nov 2009
Rookie Year: 2009
Location: Colorado Springs, Colorado
Posts: 120
karatekid has a spectacular aura aboutkaratekid has a spectacular aura aboutkaratekid has a spectacular aura about
Re: ofstream (standard C++ file output) not working

I got this from cprogramming.com:
#include <fstream>
#include <iostream>

using namespace std;

int main()
{
char str[10];

//Creates an instance of ofstream, and opens example.txt
ofstream a_file ( "example.txt" );
// Outputs to example.txt through a_file
a_file<<"This text will now be inside of example.txt";
// Close the file stream explicitly
a_file.close();
//Opens for reading the file
ifstream b_file ( "example.txt" );
//Reads one string from the file
b_file>> str;
//Should output 'this'
cout<< str <<"\n";
// b_file is closed implicitly here
}
This is how it is done in c++, for both input and output-this may not help, because I do not know how it will work with the robot, put it works for regular programs. Also, this only works for text files to my knowledge...
__________________
YOU JUST LOST THE GAME!

Last edited by karatekid : 01-10-2010 at 07:57 PM.
Reply With Quote