I am starting a project of writing a simplified shell for linux in C. I am not at all proficient with C nor with Linux that\'s exactly the reason I decided it would be a goo
if (args[i] == "&")
Ok, let's disect what this does.
args is an array of pointers. So, here you are comparing args[i]
(a pointer) to "&"
(also a pointer). Well, the only way this will every be true is if somewhere you have args[i]="&"
and even then, "&"
is not guaranteed to point to the same place everywhere.
I believe what you are actually looking for is either strcmp
to compare the entire string or your wanting to do if (*args[i] == '&')
to compare the first character of the args[i]
string to the &
character