View Single Post
  #5   Spotlight this post!  
Unread 14-07-2014, 12:57
connor.worley's Avatar
connor.worley connor.worley is offline
Registered User
FRC #0973 (Greybots)
Team Role: Mentor
 
Join Date: Mar 2011
Rookie Year: 2010
Location: Berkeley/San Diego
Posts: 601
connor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond repute
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;
}
and a sample constants file

Code:
test 1
asdf 2.0
pi 3.14
negative -12.34
__________________
Team 973 (2016-???)
Team 5499 (2015-2016)
Team 254 (2014-2015)

Team 1538 (2011-2014)
2014 Driver (25W 17L 1T)
日本語でOK