Keep getting an extra space in output

I’m stuck on Stage #TG6.

I’ve tried adding more flag variables, gave the code to ai for debugging.

Here are my logs:

remote: [tester::#TG6] Expected: "example  hello shellscript"
remote: [tester::#TG6] Received: "example  hello  shellscript"

And here’s a snippet of my code:

else if (args[0]=="echo"){
      char quote='\0';
      size_t first_quote=input.find_first_of("\"'");
      if (first_quote!=string::npos){
        string result;
        bool is_it_quote=false;
        char quote_char='\0';
        for (size_t i = 5; i < input.length(); i++){
          if (input[i]=='\''||input[i]=='"'){
            if (!is_it_quote){
              is_it_quote=true;
              quote_char=input[i];
            }else if (is_it_quote && input[i]==quote_char){
              is_it_quote=false;
            }
            continue;
          }
          
          
          result+=input[i];
        }
        cout<<result<<endl;
      }else{
        for (size_t i = 1; i < args.size(); i++){
          if(!args.empty()){
            cout<<args[i]<<" ";
          }
        }
        cout<<endl;
      }
    }

@V102002 could you upload your code to GitHub and share the link? It will be much easier to debug if I can run it directly.

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.