Hi,
I am using Visual Basic 2013. When I try and compile this program, the output is -858993460 , repeating 10 times. I am baffled.
I tried to change the encoding on my txt file, but that didn't help.
Does anyone have any ideas as to why this is happening?
Thank you,
Alexxis
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
const int ARRAY_SIZE = 10;
int numbers [ARRAY_SIZE];
int count = 0;
ifstream inputFile;
inputFile.open ("TenNumbers.txt);
while (count < ARRAY_SIZE && inputFile >> numbers[count])
count ++;
inputFile.close ();
cout <<"The numbers are: ";
for (count =0; count < ARRAY_SIZE; count ++)
cout <<numbers[count] << " ";
cout << endl;
return 0;
}
Error 1 error C2660: 'std::basic_ifstream<char,std::char_traits<char>>::close' : function does not take 1 arguments c:\users\teresa\documents\visual studio 2013\projects\test\test\source.cpp 14 1 test
ah, I misread what you wrote the first time. That is a typo from the forums, I have it in my original program. The error I posted was from me trying to put the txt file into inputFile.close- anyway, this is what I get when I run it with the proper "" in the open file:
I use Visual Studio Professional 2013, and if Visual Basic is like mine, then the way you have to organize it is weird.
For me, the input files have to be in the project directory (C:\Users\<User>\Documents\Visual Studio 2013\Projects\<name of project>) and in the same folder as the vcxproj file.
This is NOT the same place as the executable, which quite frankly makes no sense.