Thread: command line arguments

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Ushakal View Post
    Since argv[1] is expected to be a single character, he only needs to dereference argv[1]. Then the code should be:

    Code:
    if (sentence[j] == *argv[1])
    Um no. argv[ x ] is a pointer to a character. argv[ x ][ 0 ] is a single character (assuming argv[ x ] actually contains something valid).


    Quzah.
    Hope is the first step on the road to disappointment.

  2. #17
    Registered User
    Join Date
    Sep 2009
    Posts
    48
    Quote Originally Posted by quzah View Post
    Um no. argv[ x ] is a pointer to a character. argv[ x ][ 0 ] is a single character (assuming argv[ x ] actually contains something valid).


    Quzah.
    Clearly I meant that the argument input by the user is supposed to be a single character for the purposes of this program. No need to be so bloody pedantic.

  3. #18
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Ushakal View Post
    Clearly I meant that the argument input by the user is supposed to be a single character for the purposes of this program.
    I don't know how anyone who knew how command line arguments work could possibly expect that. They would have to leave a space between each letter for them to be considered their own argument. (Even then, they still end up with a string rather than just a single character.) If they didn't know how they worked, then there was room for clarification, wasn't there?
    Quote Originally Posted by Ushakal View Post
    No need to be so bloody pedantic.
    Speak for yourself.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #19
    Registered User
    Join Date
    Sep 2009
    Posts
    48
    Quote Originally Posted by quzah View Post
    Why would you think they were entering single characters separated by spaces? Because that's the only thing you could have meant by saying that each argument was its own character (which is what you are implying here).

    Since they were doing it wrong, and since you were wrong as well, there clearly is a need to be so bloody pedantic.

    If you don't like being corrected, stop being wrong.


    Quzah.
    I don't mind being corrected at all; I joined these forums to learn more about programming after all. All I ask is that you're at least polite about it. For some reason you clearly feel the need to be a douche, although I can't imagine why. I mean really, such rudeness over something so utterly insignificant.

    Clearly the OP understood what I meant, and I understand what I meant, so you are being overly pedantic.

  5. #20
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Ushakal View Post
    I don't mind being corrected at all; I joined these forums to learn more about programming after all. All I ask is that you're at least polite about it. For some reason you clearly feel the need to be a douche, although I can't imagine why. I mean really, such rudeness over something so utterly insignificant.
    I wasn't rude the first time around, and I even removed my impolite post before you submitted your reply. Clearly you needed to post what an ass I am, just in case anyone here still has some doubt. I assure you I don't care.
    Quote Originally Posted by Ushakal View Post
    Clearly the OP understood what I meant, and I understand what I meant, so you are being overly pedantic.
    You cannot, by definition, be overly pedantic. Was I being overly pedantic just then? Grab a dictionary and figure it out.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #21
    Registered User
    Join Date
    Sep 2009
    Posts
    48
    Honestly, I don't know what I've done to provoke such an unusual display of hostility. I can assure you I didn't feel the "need" to post your "impolite post", you simply deleted it while I was writing mine.

    Just forget it, this is completely pointless. I've noted my mistake, and I wont use "argv[x]" to describe a specific command line argument, regardless of its intended length, again if it makes you feel better.

  7. #22
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Ushakal View Post
    Honestly, I don't know what I've done to provoke such an unusual display of hostility.
    The first thing you did is whined like a baby about a post that had no hostility in it. Then, I showed you what minor hostility was, thought better of it, and let you on your merry way. You still cried like a baby, so I patted you on your head. Now be a good lad and run along before you tear that thin skin of yours.
    Quote Originally Posted by Ushakal View Post
    Just forget it, this is completely pointless. I've noted my mistake, and I wont use "argv[x]" to describe a specific command line argument, regardless of its intended length, again if it makes you feel better.
    See? I absolutely did need to be pedantic, because you're wrong in what you are saying you shouldn't do anymore. argv[x] does "describe a specific command line argument, regardless of its intended length".

    What it does not describe is a single character. It's not a single character. argv[x] is a character pointer. If you stopped worrying about bleeding all over the place from imaginary wounds suffered by having such thin skin, and actually looked at what I said the first time around, you wouldn't be crying, and you wouldn't be wrong in your latest statement.

    Get off the internet if you can't take the "abuse" I heaped on you in my first post.


    Quzah.
    Hope is the first step on the road to disappointment.

  8. #23
    Registered User
    Join Date
    Sep 2009
    Posts
    48
    You're just being utterly pathetic now, seriously. It's more amusing than anything, though. Oh well, nighty night.

  9. #24
    Registered User
    Join Date
    Aug 2011
    Posts
    28
    Quote Originally Posted by _Mike View Post
    Do note that you should first check argc, which you weren't doing in the code you posted in #9, to see that the user has actually written any arguments or else *argv[1] might dereference an invalid pointer.
    Of course, the completed code has all that good checking stuff. Thank you!

  10. #25
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Ushakal View Post
    Clearly I meant that the argument input by the user is supposed to be a single character for the purposes of this program. No need to be so bloody pedantic.
    We tend to be THAT picky because the compiler is THAT picky. It won't guess or adapt... it will simply report the error, which is exactly what Quzah did... Programming is like that, get used to it.

  11. #26
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    This has run it's course.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. command line arguments
    By BEN10 in forum C Programming
    Replies: 16
    Last Post: 06-04-2009, 05:43 PM
  2. Command line arguments...
    By AeonMoth in forum C++ Programming
    Replies: 5
    Last Post: 06-30-2007, 07:41 AM
  3. command line arguments
    By Mr.Pink in forum C++ Programming
    Replies: 3
    Last Post: 02-18-2005, 05:32 PM
  4. Command line arguments
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 05-02-2002, 11:59 AM