SHARE
TWEET

Untitled

a guest Jun 24th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top