So, I copied a program from my textbook to give it a test and am having output problems. The program is simple:
(When i run the program VS says the program is out of date; I don't know if the problem may be there.)
//This program reads data from a file into an array
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
const int Array_size = 10; //array size
int numbers[Array_size]; //array with 10 elements
int count = 0; //loop counter variable
ifstream inputFile; //input file stream object
//opent the file
inputFile.open("C:/TenNumbers.txt");
if (!inputFile)
{
cout << "Unable to open file" << endl;
return 0;
}
//read the numbers from the file into the array
while (count < Array_size && inputFile >> numbers[count])
count++;
//close the file
inputFile.close();
//display the numbers read
cout << "The numbers are: ";
for (count = 0; count < Array_size; count++)
cout << numbers[count] << " ";
cout << endl;
system("pause");
return 0;
}
The output is:
and the console debug is:
'project7.3.exe' (Win32): Loaded 'C:\Visual Studio 2015\Projects\project7.3\Debug\project7.3.exe'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp140d.dll'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140d.dll'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Symbols loaded. 'project7.3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'. Symbols loaded. The thread 0x6e44 has exited with code 0 (0x0). The thread 0x68ac has exited with code 0 (0x0). The thread 0x5978 has exited with code 0 (0x0). The thread 0x56ec has exited with code 0 (0x0). The program '[7220] project7.3.exe' has exited with code 0 (0x0).
Here is the contents of the text file in notepad++. I changed the encoding from UTF8 to ANSI based on info found online:
//This file supports the program7.3 in visual studio 2015 101 102 103 104 105 106 107 108 109 110

"file open"if the file couldn't be opened. You probably need to look up the concept of working directory.