

Hello, I am having a trouble with creating an 101x101 array of integers, which is very important for a project I am working on.
What I thought at first was to declare the array in the header file and then give values to its contents by an external txt file in the constructor function. However, the program doesn't recognise the txt file with the integers. Is there a specific folder, where I should copy my txt file so that Visual Studio can find it? If you can help me find my errors, or try another way to initialise my array, I would be very grateful.
My code for the constructor is this:
#include "Ttn.h"
#include
#include
#include
#include
using namespace std;
CTtn::CTtn()
{
//...
//...
// Finish initializations here
fstream fin("ook.txt");
int n=101;
//if (!fin.fail())
//{
for (x111 = 0; (x111 < n) ; x111++)
{
for (y = 0; (y < n) ; y++){
fin >> Y1[x111][y];
}
}
fin.close();
//}
}
and my header file is this:
#pragma once
// base class
#include "plugin.h"
// abstract base class for RackAFX filters
class CTtn : public CPlugIn
{
public:
// Add your code here: ----------------------------------------------------------- //
int x111;
int y;
int n;
int Y1[101][101];
Will said
Try using a complete path for the file like "C:\\SomeFolder\\ook.txt"
Notice the use of \\ to represent a single slash (see string delimiters...)
- Will
Thank you very much for your answer! This worked great for my program. I had previously tried the full path but with single slashes and it caused compilation errors.
Most Users Ever Online: 152
Currently Online:
6 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Chaes: 56
Skyler: 48
StevieD: 46
Derek: 46
Frodson: 45
Peter: 43
TheSmile: 43
Nickolai: 43
clau_ste: 39
jeanlecode: 37
Member Stats:
Guest Posters: 1
Members: 768
Moderators: 1
Admins: 6
Forum Stats:
Groups: 13
Forums: 42
Topics: 842
Posts: 3347
Moderators: W Pirkle: 689