>>Does that mean that I can't have a function with the same name as a variable anywhere in the program?<<
Well look at your program - you've got three things called "counter"...a function, a variable within the function, and a variable in main. Now this is just about breaks every accepted rule of naming conventions in C.
Even when corrected:
Code:
#include <stdio.h>
#include <stdlib.h>
int count_func();
int main()
{
int counter = 0;
counter = count_func();
printf("%d", counter);
fgetc(stdin);
return 0;
}
int count_func()
{
int counter = 0;
for (counter = 0; counter < 10; counter++)
return counter;
}
That still returns 0. I assume what you want to do is pass the value of counter in count_func to main, and print that value. Well to do this, you could use a pointer. Otherwise, you could just call the function in main, therefore outputting the value of counter. In any case, my advice is to think about what it is you want your program to do before you code it.