简体   繁体   中英

'#' 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM