Advertisement
carlos1993

cmpe 3334

Oct 17th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3. #include<stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. void parse_line(string& parse){
  8.     string word;
  9.     int count = 0;
  10.     for(int i = 0 ; i < parse.length(); i++){
  11.         if(parse[i] == '.'){
  12.             cout<<"pushing "<<word<<endl;
  13.             count++;
  14.             word.clear();
  15.             break;
  16.         }
  17.         else if(parse[i] == ' '){
  18.             if(!word.empty()){
  19.                 cout<<"pushing "<<word<<endl;
  20.                 count++;
  21.             }
  22.             word.clear();
  23.         }
  24.         else{
  25.             word +=parse[i];
  26.         }
  27.     }
  28.     if(count > 2){
  29.         cout<<"push first element as label";
  30.     }
  31.     else{
  32.         cout<<"ignore";
  33.     }
  34.  
  35. }
  36. int main(){
  37.  
  38.     //string parse = "  START 1000  .blah blah blah blah blah blha blha";
  39.     string parse = "COPY   START   1000     .blah blah blah blah blah blha blha";
  40.     parse_line(parse);
  41.  
  42.  
  43.     system("pause");
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement