Using Variables Leads To No Output


#1

For some reason when I declare a variable and compile my script, nothing is output.

#include
#include
using namespace std;

int main()
{
string text = “text”;
cout << text << endl;
cout << “text” << endl;
}

The script above leads to cmd prmpt opening with a blank line 1 and Press any key to continue on line 2. Removing the line “cout << text << endl;” leads to the same, but deleting both that line and “string text = “tex”;” leads to it outputting “text”. I am using the gpp-compiler 3.0.7 package by krisscross07 and have -std=c++11 in my C++ compiler options


#4

When posting code, remember to format it as code by highlighting your code and pressing the </>.


#5
#include <iostream>
#include <string>
using namespace std;

int main()
{
  string text = "text";
  cout << text << endl;
  cout << "text" << endl;
}

#6

Does it work when you run it with g++ from the command line?