I'm trying to write a function that will be called in main(int argc, string argv[])
for pset 2: plurality.
Inside the function, I want a for loop. I've written this:
bool vote(string name)
{
for (int x=0; x<argc; x++)
{
if (strcmp(name, candidates[x].name)==0)
{
candidates[x].votes++;
return true;
}
}
return false;
}
but when trying to compile, an error pops up. "error: expected expression"
I assume this has to do with the fact that argc is declared in main, yet I'm working in a function that's outside of main.
HOWEVER I've changed "argc" to "candidate_count" which is defined inside the main function, and it seems to work.
My question is this: Why does candidate_count work, but not argc? both are defined within the main function, so they should both work, no?