C++ Program doesn't show any output? - android-ndk

I am trying now to execute a C++ program in eclipse, but it doesn't show anything, my code is:
#include<iostream.h>
using namespace std;
int main()
{
cout<<"i have stucked here, plz do some thing for Me !";
return 0;
}
I think I am not ok in setting variable path. It is
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\QuickTime\QTSystem\;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Samsung\Samsung PC Studio 3\;C:\soft\cygwin\bin
while my bin path is
c:\cygwin\bin

Try this:
#include<iostream>
using namespace std;
int main()
{
cout<<"I am stuck here, please do some thing for Me !";
return 1;
}

remove ".h" from header iostream.h because now .h forms are deprecated from c++ library., this is working fine for me..
#include<iostream>
using namespace std;
int main()
{
cout<<"I am stuck here, please do some thing for Me !";
return 0;
}

Related

editor able to find not included file c++

My code :
main.cpp
#include <iostream>
namespace file {
#include "file.cpp"
}
namespace file2 {
#include "file1.cpp"
}
int main() {
file::hello();
return 0;
}
file.cpp
#include <iostream>
void hello() {
std::cout << "hello";
}
file1.cpp
#include <iostream>
void hello() {
std::cout << "hello world";
}
My problem:
I use virtual studio, and i don't know why this does not work.I try it allready on CodeBlock and it was fine. But in VS i have error with at least one repeatedly defined symbol has been found.
Sorry for my english.
Since VS still builds and links file.cpp and file1.cpp to the executable you get the errors. You can exclude them from the project by changing its properties or make them regular header files and include them as such.
The include will literally just copy the content of the file into the name space declaration of main.cpp.

visual c++ LNK1120 LNK2019 error

I'm a newbie, maybe it's a trivial question.
This is my code:
#include <iostream>
using namespace std;
istream& func(istream&);
int main()
{
func(cin);
system("pause");
return 0;
}
istream& fumc(istream& is) {
int num;
while (is >> num, !is.eof()) {
cout << num<<endl;
}
is.clear();
return is;
}
I got some errors LNK1120 and LNK2019.
Can someone help me?
Thank you.
Function declaration and definition has mismatch name
define it as
istream& func(istream& is)
it will work.
I think it is a linker error. Add any additional dependencies in Configuration Properties->Linker.
Hope it helps.

I can't figure out how to link msi.lib to my Visual Studio C++ project

I'm trying to write a simple application that will enumerate all the ProductCodes installed on my machine.
I've started a new project in Visual Studio 2013, but whenever I build I get the error:
"LNK2019: unresolved external symbol _MsiEnumProductsExA#32 referenced in function _main"
I've been trying to figure out how to add msi.lib to my project include path, but I can't seem to figure it out.
Here's my code:
#define _WIN32_MSI 300
#include <Windows.h>
#include <iostream>
#include <string>
#include <Msi.h>
using namespace std;
int main() {
// Get a list of all installed MSIs
DWORD index = 0;
TCHAR currentProductCode[40] = {0};
unsigned int result = ERROR_SUCCESS;
// Open an MSI handle
while (ERROR_SUCCESS == result) {
result = MsiEnumProductsEx(NULL, "s-1-1-0",
MSIINSTALLCONTEXT_USERMANAGED | MSIINSTALLCONTEXT_USERUNMANAGED | MSIINSTALLCONTEXT_MACHINE,
index, currentProductCode, NULL, NULL, NULL);
if (result == ERROR_SUCCESS) {
cout << "current ProductCode: " << currentProductCode;
}
index++;
}
return 0;
}
I've been trying to update the project's Property Pages by adding the path to the msi.lib to the "Library Directories" property, but that doesn't seem to work:
This is like Visual Studio 101, what am I missing?!
Goto Configuration Properties>Linker>Input
Add msi.lib in Additional Dependencies Thats it! Make sure you are using same calling conversion, which used to built the lib. i.e either stdcall or cdecl.

visual studio 2013 C++ - console output not visible

Recently i installed visual studio community edition and tried to write small console application.
Program is getting build successfully. But console window is not getting pop up.
Is there a problem, i installed the visual studio on my System "D" drive.
My code snippet :
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main() {
cout << "Hello world";
return 0;
}
Kindly help
Add a cin.get() like so:
int main() {
cout << "Hello world";
cin.get(); // <- Waits for any key press directed at the console window
return 0;
}

Inputting a string

Can't compile something as simple as this, yet when I change the variable type from
string to int, it compiles and runs fine. Any ideas why this is happening?
#include <iostream>
using namespace std;
void main()
{
string x;
cin>>x;
}
You need:
#include <string>
To get std::string in your application.

Resources