Hot answers tagged

2

candidate_count is not declared in main. It's a global variable (declared outside of main) on line 20 in the distribution file plurality.c at the time of this writing. The definition of main starts later on line 26. That's why you're able to see candidate_count in other functions. argc, on the other hand, is a local variable that you can reference only ...


1

An empty linked list consists only of a NULL pointer, no node. There is no dedicated "head" node, just a "head" pointer pointing to the first node (and if there's none, it's NULL). So you could just use your while loop without any if with special treatment for first node. You forgot its next pointer in that part, but everything is covered by your while. BTW,...


1

Interesting question. The answer is that a global variable does not work in your program. The compiler warning is really telling you that the variable a, in main, is different from the variable a in the increment function. Again, the increment function is passed a local copy of a, and is only increased locally, but not globally as you intended. To check, you ...


Only top voted, non community-wiki answers of a minimum length are eligible