Hello! New to C++ and going through the C++ primer. I built out this code, and it was working just a moment ago, but now it doesn't seem to be working. I decided to copy the original code from the textbook, and it looks as that is also having build errors. I'm using Visual Studio as my IDE, and yeah I just feel stumped as to why it's not working. The debugger says everything is clear. Could it be something with my IDE?
#include <iostream>
int main()
{
int currVal = 0 /*Which number is counted*/, val = 0; /*Holds number from input*/
// read first number and ensure that we have data to process
if (std::cin >> currVal) { //if the datastream can be read
int cnt = 1; //no matter what this statment only executes once.
while (std::cin >> val) { // read the remaining numbers
if (val == currVal) { // if the values are the same
++cnt;
//std::cout << "if statment hit! \n";
}
else {
std::cout << currVal << " occurs " << cnt << " times" << std::endl;
currVal = val;
cnt = 1;
//std::cout << "else statment hit! \n";
}
}
// remember to print the count for the last value in the file
std::cout << currVal << " occurs " << cnt << " times" << std::endl;
}
return 0;
}
ERROR MSG
Build started...
1>------ Build started: Project: CPP-Primer-Exericse-1-4-4, Configuration: Debug x64 ------
1>Source.cpp
1>LINK : fatal error LNK1168: cannot open C:\Users\Chowd\Desktop\CPP-Primer\CPP-Primer-Exericse-1-4-4\x64\Debug\CPP-Primer-Exericse-1-4-4.exe for writing
1>Done building project "CPP-Primer-Exericse-1-4-4.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Elapsed 00:00.901 ==========

