|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Reference text file in C++
I know that it is possible to reference a text file in C++ so that you are able to change variables without having to rebuild every time you want to change a constant. Does anyone know how to do that, and if so could you tell me how?
Thanks, E Dawg |
|
#2
|
|||
|
|||
|
Re: Reference text file in C++
Check out RAWCConstants.
It was developed by other FRC teams and we stole shamelessly. It's been super useful. Edit: it was pointed out to me that I was violating the license agreement. I've removed the link to our repo. I'm not sue the official source for the tool. I wasn't part of our original implementation. Last edited by Jefferson : 12-07-2014 at 21:17. Reason: Licensing stuff |
|
#3
|
||||||
|
||||||
|
Re: Reference text file in C++
How much do you understand about file i/o in general?
|
|
#4
|
|||
|
|||
|
Re: Reference text file in C++
Not that much. I've never really worked with it before.
|
|
#5
|
|||||
|
|||||
|
Re: Reference text file in C++
A simple way to do this in C++
Code:
#include <fstream>
#include <string>
#include <map>
...
std::ifstream constants("constants.txt");
std::map<std::string, double> data;
std::string name;
double value;
while(constants >> name >> value)
{
data[name] = value;
}
Code:
test 1 asdf 2.0 pi 3.14 negative -12.34 |
|
#6
|
||||
|
||||
|
Re: Reference text file in C++
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|