For keeping the variable, it must be static. Here is it explained:

http://www.geeksforgeeks.org/static-variables-in-c/