Thread: command line param question

  1. #1
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946

    command line param question

    with
    Code:
    int main (int argc, char *argv[])
    i know i can test for
    Code:
    if (argv[argc])
    and it will return false. but can i test for
    Code:
    if (argv[argc + 1])
    and know that it will safely return false? i don't think so, but i'm not sure...
    hello, internet!

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    argv[argc] is guaranteed to be NULL, argv[argc + 1] exceeds the array boundaries for argv. So your test would result in undefined behavior.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM