I have read many times that to end a program and keep the console window open you have to add in, std::getchar(); ,and I have that in there on the last line. Works perfectly if I run it from visual studio 2015 but when I build the exe and run it from the exe it flashes the result and closes before you can read the result. Ok, enough of the explaination of my problem and now for the code. I wrote this program today, it is my very first program that was not copied. I have had help in a couple spots on different threads but the jist of it was from me. I am trying to write programs to learn c++ from.
#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <istream>
usingnamespace std;
int main()
{
// creating a string variable to hold a word
string word = "";
// Ask user to input a word to be translated to "PIG_LATIN"
cout << ("Enter a word to be translated to PIG_LATIN:\n");
cin >> word;
word += "ay";
int lengthOFword = word.length();
// subtract 1 from lengthOFword so that the 'a' remains at the end
lengthOFword -= 3;
// move first letter the distance of lengthOFword and places it before the 'a'
char move_letter = word[0];
for (int x = 0; x < lengthOFword; x++)
word[x] = word[x + 1];
word[lengthOFword] = move_letter;
//print the final product
cout << (word) << endl;
std::getchar();
}