No matching constructor for initialization of string

std::ifstream Auton(“test.txt”);

std::string doot((std::isstreambuf _iterator(Auton), //where the error is std::istreambuf_iterator()); > > std::ifstream Auton(“test.txt”);

The code is to load a text file and save integers into an array. The “std::string doot” is the point of the error. What’s wrong with this code that it’s coming up with that error?

You didn’t really need to create a new topic. I’m not sure why you’re struggling so much with this, but your code should be something like this

#include "vex.h"
#include <fstream>

int main() {
  std::ifstream Auton("test.txt");

  std::string doot((std::istreambuf_iterator<char>(Auton)), std::istreambuf_iterator<char>());

  char shadow_auton[doot.length() + 1];
  strcpy(shadow_auton, doot.c_str());
1 Like

Well I’m struggling because there is constant new errors. NOW it’s ok. Thank you. If anyone gets an error about strcpy not existing, check if there’s a 2d array in the line defining the character.