I'm trying to open a csv file for testing but it always comes back to me "" Unable to open file "" and I can't figure out what I'm doing wrong. can anyone help me?
void testBSTWithInteger() {
string line;
ifstream myfile ("C:\\Users\\danie\\Desktop\\DatastructuresV2\\tests\\bstint.csv");
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
char c[line.length()];
strcpy(c, line.c_str());
auto bst = new BST<int>();
for (int i= 0; i<line.length(); i++) {
if (c[i] == 2) {
bst->insert(c[i]-48);
assert(bst->root->data == 2);
assert(bst->root->left == nullptr);
}
if (c[i] == 1) {
bst->insert(c[i]-48);
assert(bst->root->left->data == 1);
}
if (c[i] == 3) {
bst->insert(c[i]-48);
assert(bst->root->right->data == 3);
bst->deleteNode(2);
assert(bst->root->data == 3);
bst->deleteNode(3);
assert(bst->root->data == 1);
bst->deleteNode(1);
assert(bst->root == NULL);
}
}
}
myfile.close();
}
else cout << "Unable to open file";
}
Aucun commentaire:
Enregistrer un commentaire