-
Notifications
You must be signed in to change notification settings - Fork 1
/
stack.c
45 lines (37 loc) · 924 Bytes
/
stack.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
// variables in the help
void doSomething();
void doSomethingElse();
int global=42; //global variable for this file
void swap(int*, int*);
int main(){
int a = 10, b = 20;
printf("a is %d and b is %d\n", a, b);
swap(&a,&b);
printf("a is %d and b is %d\n", a, b);
// doSomething();
// printf("finished doSomething()\n...");
// doSomethingElse();
// printf("finished doSomethingElse()\n");
printf("main function is done...\n");
return EXIT_SUCCESS;
} // end main method
void doSomething(){
// how many times this function is called
static int counter = 0;
counter++;
printf("working on something...\n");
};
void doSomethingElse(){
printf("I'm calling doSomething()...\n");
doSomething();
printf("I'm done calling doSomething()...\n");
printf("working on something...\n");
};
void swap(int *x, int *y){
int tmp = *x;
*x = *y;
*y = tmp;
};