Hi
I'm working on improving the "Simpletron" computer described in Deitel
& Deitel's "C++ How to Program" 3rd edition. Check out
http://www.lehigh.edu/~ejk0/smlspec.pas for a description if you're
curious.
I'm trying to add my own opcodes for string input/output using the
string type from string.h
At the top of my program, directly underneath my definition of the
normal (signed integer) memory array declaration I've got this:
"string smem[100];" (without quotes, of course)
In my switch statements that perform the operations defined by the
opcodes, I've got this:
case SIN:
cout << "s? ";
getline(cin, smem[opData]);
break;
case SOT:
cout << "Output:" << smem[opData];
break;
(note that I have const int SIN = 50; and const int SOT = 51; up with
my other opcode definitions. opData is equal to the memory location
specified by the second two numbers in each instruction.)
Running the program and entering the following program I get this
output:
00: 5001
01: 5101
02: -9999 [the sentinel to end program entry]
---Beginning Program execution---
s? Joe
Output:
---Program Execution Complete---
Press any key to continue . . .
No matter what I do, I can't get it to output the string.
Any clue what I'm doing wrong?
Thanks
Pulsar