Errors in C++ Hello World program - c++

Installed c++ in visual studio 2019 some time ago and it worked perfectly. Today when I launched I got 490 errors. This is a screenshot of what a Hello World looks like: https://imgur.com/yxIs9Np
I am completely new to c++ so I dont know whats wrong, I have tried to search for the error but I could not find anything. I have tried to reinstall c++ in vs and updated vs to the newest version.
code:
#include <iostream>
int main() {
std::cout << "Hello World!\n";
}
its nothing wrong with the code, I think something is wrong with the librarys. For some reason I get 17 errors " cannot open file "[Some name].h" "

Reinstalled visual studio, this worked. The problem was that it dident include C:\Program Files (x86)\Windows Kits\10

Related

C++ Hello world keeps giving me errors in Visual Studio 2019

I'm just trying to print hello world using C++ but all I get is build errors. The error list shows 412 errors and they're mostly "Cannot open source file" followed by a file name that I haven't heard of.
It also says the WindowsSDKDir property is not defined and the solution I found was to repair visual studio when I looked up this problem. I completed repairing visual studio and I have the C++ selected in the workloads.
Even when I select "Console App" during initial set up it'll end up giving me the same errors even though that is supposed to set up a basic environment for Hello World.
My code is simply just to print out hello world.
#include <iostream>
void output();
int main()
{
output();
}
void output()
{
std::cout << "Hello World!" << std::endl;
}
So I just uninstalled Visual Studio completely and then reinstalled it. I realized I could have just modified it using the installer, but basically after selecting the C++ workload I made sure every box was selected on the right hand side. I don't know if I needed it all but I just installed everything to be sure and it finally worked.

"Project out of date" in VS community 2017

I recently changed from Microsoft Visual Studio Community 2015 (which worked fine) to the 2017 version, and at first, it was working fine. I save my projects in C:/_Dev/C++/My projects/. However, after using 2017 for less than 3 hours, I now get this message whenever I try to run a project:
"This project is out of date:
[insert file name]-Debug Win32"
Then I have the option to build it or not, and building does still work, but I don't like that something is going slightly wrong.
Note that since I got this error, I went back to my first C++ program to see if it now displays the message too, which it does. The code is as follows:
#include <iostream>
using namespace std;
void main()
{
cout << "Hello World!";
system("pause");
}
...So I'm fairly confident it's not my code causing the issue. It's been a couple of days since I started getting the error, and I've tried re-installing VSC 2017, deleting the *tlog files, cleaning, and rebuilding the project. I have not moved the project to a new file directory since its creation.
Does anyone know if this will turn into a big problem, or is it just something I have to put up with? If anyone knows more, I'd appreciate the advice.

Simple Visual Studio console application does not start

I installed Visual Studio 2013 on my Windows 10 machine. To test the installation I wrote a simple program in C++:
#include <iostream>
using namespace std;
int main(){
cout << "Size of char is: " << sizeof(char);
cin.get();
return 0;
}
It's embarrassing to post such a simple code here but the problem is as follows. The build process runs without errors or warnings. But when I start the program via Debug-Button, Visual Studio freezes. I also tried starting the .exe in cmd. The result is a blinking cursor in an empty line with no further reaction from the console.
Can somebody tell me what's wrong? The Project Type in Visual Studio is empty visual c++ project.
Finally it works. As Peter M mentioned in his comment, the VS/Avast issue was the problem.

fatal error C1083: Cannot open include file: 'iostream': No such file or directory

I've reinstalled Visual Studio 2010 Professional several times to try to get it to work.
I had to uninstall Visual Studio 2012 Professional because it wasn't compiling something we did in class.
I completely uninstalled everything including SQL Server..
I went to VC/include and the iostream header file is not there.
#include <iostream>
int main () {
cout << "hello";
system ("PAUSE");
return 0;
}
This is all I'm trying to do because nothing else is working.
It's really driving me crazy because I need to get it working so that I can do my project!!!
Every time I do; new project => empty project => add an item to source =>.cpp
I'm running windows 8.
It just says Error cannot open source file
Also, error cout identifier is undefined....
I'm wondering if I should do a system restore?
Or if I should just completely reinstall windows 8 from my recovery media?
One problem is that you did not include the namespace std.
This is what your code should look like:
#include <iostream>
using namespace std;
int main (void) {
cout << "hello" << endl;
system("pause");
return 0;
}
or you could have done something like this: std::cout << "Hello" << std::endl;
This may be a problem because you did not set your environment to C++. This is how you do it:
Go to Tools > Import and Export settings. If you cannot find it, just search for it in Quick Search
Then go to reset all settings.
Then simply select "Visual C++"
Restart.
That should do the trick. If it does not, you might consider re-installing Visual C++ itself. For VS 2012. If that does not work, then re-install the program.
if it is problem with visual studio 2012, install this update.

wchar and stdout in VC11

I've found a weird issue with outputting wide chars in Visual Studio 2012 which I've narrowed down to the following code.
#include <cstdio>
int main()
{
fputws(L"Hello World\n", stdout); // Throws Access Violation exception
}
When compiling this with Visual C++ 2012 it throws an "Unhandled exception", "Access violation reading location 0x00000064", somewhere inside fputws.
What I'm using to compile is with is the CLI version, just to rule out any settings in the IDE. I am opening the Visual Studio Command Prompt and using the following:
cl test.cpp
When using Visual Studio 2008 or Visual Studio 2010 it works well, writing out "Hello World".
But when using Visual Studio 2012, it crashes with the above mentioned error.
I have a hard time believing it's a compiler issue but rather something that's changed between the different versions of C++.
Another (funny) thing is that if I output a normal char first, like the code snippet below, it works just fine. So what I think is that it is an issue with uninitialized streams?
#include <cstdio>
int main()
{
fputs("", stdout);
fputws(L"Hello World\n", stdout); // Now this works.
}
Anyone got any ideas?
Edit:
The following, similar, functions works fine in VS2012:
std::wcout << L"Hello world" << std::endl;
wprintf(L"Hello world\n");
_putws(L"Hello\n", stdout);
putwchar(L'H');
Edit 2:
Just filed a bug report to microsoft.
I had this problem on a RTM VS2012 but didn't on VS2012 Update 1. After installing Update 1 on the problem system the error disappeared. Thanks to Mats for reporting this.