Using argv in C?

前端 未结 6 1346
难免孤独
难免孤独 2020-12-03 22:37

For an assignment, I am required to have command line arguments for my C program. I\'ve used argc/argv before (in C++) without trouble, but I\'m unsure if C style strings ar

6条回答
  •  旧巷少年郎
    2020-12-03 23:04

    You can't compare c-strings like that. Use strcmp (reference here).

    Because c-strings are actually pointers, the == operator compares the address of the first character which will never be equal in this case.

提交回复
热议问题