Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float NGLScene::readStartPos()
- {
- stringFromFile("configFile.txt");
- getValues(myFileContents);
- for(int i=0; i < 2;)
- {
- float x = retVec.pop_back();
- std::cout<<x;
- }
- }
- //A function to get the contents of a file as a string
- std::string stringFromFile(std::string _filename)
- {
- std::ifstream myFile(_filename);
- std::string myFileContents((std::istreambuf_iterator<char>(myFile)), std::istreambuf_iterator<char>());
- std::cout<<"hello";
- return myFileContents;
- }
- //Using:
- //http://www.cplusplus.com/reference/string/string/substr/
- //http://www.cplusplus.com/reference/string/string/find/
- std::vector<float> getValues(std::string _stringIn)
- {
- std::vector<float> retVec;
- int startPos = 0;
- for(int i = 1; i < 3; i++)
- {
- std::size_t delimPos = _stringIn.find(";", startPos);//Assuming that ';' is your delimiting character
- std::size_t lineEndPos = _stringIn.find("\n", startPos);//Should work, not sure
- retVec.push_back(std::stof(_stringIn.substr(delimPos, lineEndPos)));
- startPos = lineEndPos;
- }
- return retVec;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement