Originally posted by Roaring_Tiger
Any alternative idea, without writing much code.
That's really going to depend on how you design your program and what it's actually supposed to be doing.
How about this:
Code:
#include <stdio.h>
void foo(int accountNum)
{
static int Prev_accountNum; /* init to 0 by default */
printf ("This time: %d\nLast time: %d\n", accountNum, Prev_accountNum);
Prev_accountNum = accountNum;
}
int main(void)
{
foo(10);
foo(20);
foo(30);
return 0;
}
/*
* Output
This time: 10
Last time: 0
This time: 20
Last time: 10
This time: 30
Last time: 20
*
*/