I'm trying to implement a resizable array class in C++. I started out with a basic C++ Console Application Template.
I'm unable to build the basic Hello World program in Visual Studio 2022.
This is all the code in my main.cpp file-
#include <iostream>
using namespace std;
int main()
{
std::cout << "Hello World!\n";
return 0;
}
And these are my build logs for the above project.
Related
I'm trying to run a program that prints out "hello" just to see if I can get C++ to run on my machine (running Windows 10 Home and Visual Studio 17.0.5). When I compile the program, I get all kinds of errors that seem to point to files that I haven't even included in my program:
#include <iostream>
#include <string>
using namespace std;
int main() {
cout << "hello";
return 0;
}
screenshot of errors
I am using Visual Studio 2019 and developing in C++.
I have installed Microsoft Cognitive services by following this walkthrough and my pakcages.config looks correct.
Now when following this tutorial to use cognitive speech, my c++ solution will not build stating "Microsoft is not a class or namespace name"
This shows the error and the sample code and the packages.config file
code and error screenshot
packages.config
I suggest that you could add speechapi_cxx.h in Properties->VC++ Directories->Include Directories.
The path is cognitive-services-speech-sdk-master\quickstart\cpp\windows\from-microphone\packages\Microsoft.CognitiveServices.Speech.1.15.0\build\native\include\cxx_api.
Also, you need to add the code using namespace Microsoft::CognitiveServices::Speech::Audio;.
Here is the complete codeļ¼
#include <iostream>
#include <speechapi_cxx.h>
using namespace std;
using namespace Microsoft::CognitiveServices::Speech::Audio;
using namespace Microsoft::CognitiveServices::Speech;
auto config = SpeechConfig::FromSubscription("real_sub_id", "region");
int main()
{
std::cout << "Hello World!\n";
auto audioCofig = AudioConfig::FromDefaultMicrophoneInput();
auto recognizer = SpeechRecognizer::FromConfig(config, audioCofig);
cout << "Speak " << endl;
auto result = recognizer->RecognizeOnceAsync().get();
cout << "RECOGNIZED: Text=" << result->Text;
}
I don't know much about the library you are using, but i am sure that you need to #include something before you can actually use the library.
I'm following this tutorial to create a C++ Hello World app for Visual Studio.
https://tutorials.visualstudio.com/cpp-console/install
I've installed the software, selected "Windows Console Application" and copy/pasted the Hello World program from the tutorial:
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, world!\n";
return 0;
}
However, when I try to run the Local Windows Debugger, I get this error:
Unable to open program.
\repos\HelloWorld\Debug\HelloWorld.exe
The system cannot find the file specified.
How would I include an .exe file?
Also, I have an error "cannot open stdafx.h", but I assume that's connected to this.
EDIT:
I removed "#include "stdafx.h"" and got the same error. It also said there was an unexpected end of file and suggested I #include "pch.h", so I did.
#include <iostream>
#include "pch.h"
using namespace std;
int main()
{
cout << "Hello, world!\n";
return 0;
}
I'm still getting the error that it can't find .exe ...also 'cout' is an undeclared identifier.
I am creating a Windows console application using visual studio 2017, but the console only accepts c code. I am trying to enter:
#include <iostream>
int main()
{
std::cout << "Hello World";
}
It gives some errors like saying "cout" doesn't exist, "std" doesn't contain "cout" and many others. However if I change the code to:
#include "stdafx.h"
int main()
{
printf("Hello World");
}
It works fine. How do I make it accept c++ code?
I try to build a simple piece of code in Visual Studio, but the building process gets entangled in an infinite loop.
The code is simple:
// test.cpp : Defines the entry point for the console application.
//
#include <iostream.h>
using namespace std;
int main(void)
{
cout << "Hi." << endl;
return 0;
}
Any idea what is going on?
Thanks.
spot several things:
not sure what's in 'stdafx.h'
#include < iostream >
std::cout, std::endl (unless using namespace std; somewhere)
Build works fine for me, though.