-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC_Long_Form.c
73 lines (73 loc) · 1.56 KB
/
C_Long_Form.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
////////////////////////////////////////////////
// C_LONG_FORM of the village hidden in the 1337
// VERSION: 1 ------------------------------skrp
#include <stdio.h>
#define MAX 10
void pntr(int *, int *);
void arr(int *);
int strln(char *);
void prtstr(char *);
int main()
{
int a=10, b=3, i=0, *c;
// main variable addr
c=&b;
printf("a_addr=%p %d\nb_addr=%p %d\nc_addr=%p %d\n\n", (void*)&a,a, (void*)&b,b, (void*)c, *c);
// main variable changed in fn
pntr(&a, &b);
printf("a+=1 = %d\nb*=2 = %d\n\n", a, b);
// pointer arithmetic
*c+=4;
printf("*c+=4 = %d\n++(*c) = %d\n", *c, ++(*c));
// array
int d[10], *e, z=0;
char *f="ducki&dicki", *g="fktheworldz";
// loop
while (z<MAX)
{ d[z]=z*10; z++; }
e=d;
printf("\n*(e+5) = %d\n", *(e+5));
e+=9;
printf("e+=9 = %d\n", *e);
// array change in fn
arr(d);
printf("fn array change %d\n", *(d+3));
// string
printf("\nconstant %d\nptr string %d\nstrln(f+4) %d\n", strln("fkutoo"), strln(f), strln(f+4));
// pointer-array
i=0;
char *day[]={"monday","tues","wednesday","thurs","friday","sat","7"};
prtstr(day[2]);
printf("%c\n", day[3][2]);
//multi-d-array
int list[3][5] = {
{8,3,0,0,0},
{0,1,3,3,7},
{21,23,24,25,26}};
printf("%d\n", list[2][3]);
return 0;
}
void pntr(int *x, int *y)
{
*x+=1; *y*=2;
printf("fn_a_addr=%p\nfn_b_addr=%p\n", (void*)x, (void*)y);
}
void arr(int *a)
{
a[3] = 33;
printf("\nfn_arr_change=%d\n", *(a+3));
}
int strln(char *p)
{
int n;
// iterate
for (n=0; *p!='\0'; p++)
n++;
return n;
}
void prtstr(char *c)
{
while(*(c) != '\0')
printf("%c", *(c++));
printf("\n");
}