Click here to Skip to main content
15,917,953 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: serial port communication Pin
Murlai18-Oct-04 19:02
Murlai18-Oct-04 19:02 
Generalfile problem Pin
Anonymous18-Oct-04 13:12
Anonymous18-Oct-04 13:12 
GeneralRe: file problem Pin
RobJones18-Oct-04 13:14
RobJones18-Oct-04 13:14 
GeneralRe: file problem Pin
Azghar Hussain18-Oct-04 19:01
professionalAzghar Hussain18-Oct-04 19:01 
GeneralRe: file problem Pin
Murlai18-Oct-04 19:26
Murlai18-Oct-04 19:26 
GeneralException handling Pin
RobJones18-Oct-04 13:09
RobJones18-Oct-04 13:09 
GeneralRe: Got a little further.. but still need help Pin
RobJones18-Oct-04 17:40
RobJones18-Oct-04 17:40 
Generali need help!!!!!!! Pin
DaBlueSage18-Oct-04 13:00
DaBlueSage18-Oct-04 13:00 
i'm tryin to do this program and i don't know how to go about doing it. i tried it one way but it didn't work.

The goal of the program is to encode input messages using the following encryption strategy:
The message sender iputs a four letter word , CCCC, and another for letter word XXXX. The message sender then inputs the message to be sent. The program scans the message one character at a time and each character is pushed in the stack until either the scanned character is in the word CCCC or the end of message is encountered. When the scanned characters in CCCC, print that charcater until the stack is empty or the chracter at the top is one of the chracters XXXX. Whne the end of the message is encountered, print the chracter at the top of the stack and continue to pop and print the stack top until the stack is empty.

for example:
word 1 = GOOD
word 2 = LUCK
message to be encoded = SOUNDS SIMPLE TO ME
encoded message = OSDNOT EEM LPMIS SU

this is what i have so far:

#include <cctype>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

class stack
{
private:
char stacks[50];
int top;

public:
void push(char);
char pop(char &);
bool empty();
bool full();
stack()
{
top=0;
}
};

bool stack::empty()
{
if (top==0)
return true;
else
return false;
}

bool stack::full()
{
if (top==50)
return true;
else
return false;
}

void stack::push(char x)
{
if (full())
exit(1);
else
top++;
stacks[top]=x;
}
char stack::pop(char &x)
{
if (empty())
exit(1);
else
x=stacks[top];
top--;
return (x);
}


int main()
{
stack s1;
char word1[5];
char word2[5];
char message[50];
int len;


char catchvar;

cout<<"Enter Encryption word 1 : ";
cin.getline(word1,5);
cout<<"Enter Encryption word 2 : ";
cin.getline(word2,5);
cout<<"Enter message to be encypted : ";
cin.getline(message,50);
len=strlen(message);
cout<< "Encypted message is : ";



for (int i=0; i<5; i++)
{
for(int j=0; j
GeneralRe: i need help!!!!!!! Pin
l a u r e n18-Oct-04 15:25
l a u r e n18-Oct-04 15:25 
GeneralRe: i need help!!!!!!! Pin
bryce18-Oct-04 20:39
bryce18-Oct-04 20:39 
GeneralConversion between multibyte and UNICODE Pin
Vancouver18-Oct-04 12:32
Vancouver18-Oct-04 12:32 
GeneralRe: Conversion between multibyte and UNICODE Pin
l a u r e n18-Oct-04 15:26
l a u r e n18-Oct-04 15:26 
GeneralRe: Conversion between multibyte and UNICODE Pin
Vancouver18-Oct-04 15:50
Vancouver18-Oct-04 15:50 
GeneralRe: Conversion between multibyte and UNICODE Pin
PJ Arends18-Oct-04 16:09
professionalPJ Arends18-Oct-04 16:09 
GeneralRe: Conversion between multibyte and UNICODE Pin
Vancouver18-Oct-04 17:54
Vancouver18-Oct-04 17:54 
GeneralRe: Conversion between multibyte and UNICODE Pin
PJ Arends19-Oct-04 5:21
professionalPJ Arends19-Oct-04 5:21 
GeneralRe: Conversion between multibyte and UNICODE Pin
Vancouver19-Oct-04 6:15
Vancouver19-Oct-04 6:15 
GeneralCopy Constructor Pin
Malcolm Smart18-Oct-04 10:46
Malcolm Smart18-Oct-04 10:46 
GeneralRe: Copy Constructor Pin
David Crow18-Oct-04 11:18
David Crow18-Oct-04 11:18 
GeneralRe: Copy Constructor Pin
Malcolm Smart18-Oct-04 11:37
Malcolm Smart18-Oct-04 11:37 
GeneralRe: Copy Constructor Pin
David Crow18-Oct-04 16:16
David Crow18-Oct-04 16:16 
GeneralWM_CLOSE message Pin
help_wanted18-Oct-04 9:10
help_wanted18-Oct-04 9:10 
GeneralRe: WM_CLOSE message Pin
David Crow18-Oct-04 9:19
David Crow18-Oct-04 9:19 
GeneralRe: WM_CLOSE message Pin
help_wanted18-Oct-04 9:35
help_wanted18-Oct-04 9:35 
GeneralRe: WM_CLOSE message Pin
David Crow18-Oct-04 10:27
David Crow18-Oct-04 10:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.