Petr Jašíček
Petr Jašíček

Reputation: 143

'#' or '&' characters terminating C++ command line arguments

I have following problem:

When I have command line argument beginning with '&' or '#' character it does not count as argument, example:

~$ ./ircbot irc.felk.cvut.cz #ISAchannel 192.168.0.1

Now the argc = 2 (it should be 4)

~$ ./ircbot irc.felk.cvut.cz ISAchannel 192.168.0.1

Now the argc = 4 as it should be

Is this caused by shell recognizing these special characters or something ?

Thanks.

Upvotes: 0

Views: 98

Answers (1)

Brian Bi
Brian Bi

Reputation: 119069

In shell, # comments out the rest of the line. You'll have to escape it:

./ircbot irc.felk.cvut.cz \#ISAchannel 192.168.0.1

or

./ircbot irc.felk.cvut.cz '#ISAchannel' 192.168.0.1

Upvotes: 3

Related Questions