Harry
Harry

Reputation: 3074

"single" command line argument which contains spaces is getting treated as multiple arguments

In godbolt compiler explorer (https://godbolt.org/z/Gqc5PeKz8) I am passing a single argument which contains spaces inside quotes, but it looks they are getting treated as separate arguments:

#include <iostream>

int main(int argc, char * argv[]) {
    std::cout << argc << ", " << argv[1] << std::endl;

    return 0;
}

Execution Arguments:

"a b c"

Output:

4, "a

I tried various options like single quote, double quote and putting a special symbol(\) before space.

Upvotes: 2

Views: 75

Answers (0)

Related Questions