Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. string input;
  2. while(input != "DONE"){
  3. if(input == "DONE"){
  4. break;
  5. }
  6. cout<<"Enter the opcode/operand to enter an instruction or 'DONE' to exit: ";
  7. cin>>input;
  8.  
  9.  
  10. // Seperate input
  11. bool opcode_bool = true;
  12.  
  13. string opcode;
  14. string operand;
  15. for(int i = 0; i < input.length(); i++){
  16. if(input[i] == ' '){
  17. opcode_bool = false;
  18. continue;
  19. }
  20.  
  21. if(opcode_bool == true){
  22. opcode = opcode + input[i];
  23. }else{
  24. operand = operand + input[i];
  25. }
  26.  
  27. }
  28.  
  29. cout<<opcode<<endl<<operand<<endl;
  30. cout<<"END OF ITERATION"<<endl;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement