What I need to do is... make the output continuous. For example when I input a number it displays character it represents in the current message line. What I need is for each input to add to the next line. In other words when I input 39 I get G as current my next input is 79 and my output should be Go, however I just get the most recent input and not the string that i am inputting. Help please or suggestions. Thanks


This is my code:

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;


string message; // holds the decrypted message

 // Function Prototype

char decryptedLetter (int encryptedLetter);

void main(void)

{

	int num = 0;
do
{
	cout <<"\nEnter encrypted letter ( 0-94: -1 to exit): ";
	cin >> num;
	cout <<"Current message: " << decryptedLetter(num)<< endl;
	
	message += decryptedLetter(num);
	
	
}
while(num >= 0 && num < 94 && num !=-1);
  
	cout << endl;

	cout << "\n"; // insert newline for readability

return;
}

char decryptedLetter (int x)

{
	char encryptedLetter;
	encryptedLetter = x +32;
	return encryptedLetter;

Please put your code in code tags in the future.

The variable message is building just fine. The problem is, you're only writing out the current decrypted letter:

cout <<"Current message: " << decryptedLetter(num)<< endl;

Change your code to first append the new letter, and then print the string (not the letter), and you should be fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.