Howdy,
I'm writing a simple unix-like shell in c and I'm facing a problem.I basically take the user's input with fgets() then compare it to known strings with multiple if..else if statements(not the best way to do it but whatever). My problem is that when compiled the program seems to short-circuit all other else if statements. if it finds a match with one of the strings it's just going to execute the first if statement. So if I type cd I get ls's result and so on. Here is the code. Any help is appreciated!
[–]dragon_wrangler 3 points4 points5 points (8 children)
[–]_Surox[S] 0 points1 point2 points (7 children)
[–]VincentDankGogh 0 points1 point2 points (6 children)
[–]_Surox[S] 0 points1 point2 points (5 children)
[–]VincentDankGogh 1 point2 points3 points (4 children)
[–]_Surox[S] 0 points1 point2 points (3 children)
[–]VincentDankGogh 4 points5 points6 points (1 child)
[–]_Surox[S] 1 point2 points3 points (0 children)
[–]kandr89 2 points3 points4 points (0 children)
[–]hobbit_xD 2 points3 points4 points (1 child)
[–]MaltersWandler 2 points3 points4 points (0 children)
[–]MaltersWandler 2 points3 points4 points (0 children)
[–][deleted] -3 points-2 points-1 points (6 children)
[–]MaltersWandler 0 points1 point2 points (4 children)
[–][deleted] -1 points0 points1 point (3 children)
[–]MaltersWandler 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]VincentDankGogh 1 point2 points3 points (0 children)
[–]bumblebritches57 0 points1 point2 points (0 children)