You want to use strcmp() == 0
to compare strings instead of a simple ==
, which will just compare if the pointers are the same (which they won’t be in this case).
args[i]
is a pointer to a string (a pointer to an array of chars null terminated), as is "&"
or "<"
.
The expression argc[i] == "&"
checks if the two pointers are the same (point to the same memory location).
The expression strcmp( argc[i], "&") == 0
will check if the contents of the two strings are the same.