Trying Not To Use Global Variables With Function
I want to have this function plus a variable by one. and it does. But i want to do it without using global variables, as i have read it is poor design. Does that mean you don't need to declare variables at all? I have seen this work that way (i think), but no matter what I seem to need to declare the int x in order to make this work.
How can i make this work without global variables, and do i need to declare x at all?
Code:
#include<stdio.h>
/*local function prototype*/
int plus();
/*main function*/
int main(int argc, char * argv[])
{
x = 1;
printf("x = %d \n",x);
/*impliment the plus function*/
x = plus(x);
printf("\nx = %d",x);
getch();
return 0;
}
/*local function*/
int
plus(int input)
{
return input + 1;
}