-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExam2.c
More file actions
80 lines (80 loc) · 1.67 KB
/
Exam2.c
File metadata and controls
80 lines (80 loc) · 1.67 KB
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
74
75
76
77
78
79
80
//#define _CRT_SECURE_NO_WARNINGS
//
//#include<stdio.h>
//#include<stdlib.h>
//#include<string.h>
//
//struct Student
//{
// unsigned char* cod;
// float medie;
//};
//
//typedef struct Student Student;
//
//struct Nod {
// Student st;
// struct Nod* next;
//};
//typedef struct Nod Nod;
//
//
//void functie(Nod** p, Student s)
//{
// Nod* nou;
// nou = (Nod*)malloc(sizeof(Nod));
// nou->st = s;
// nou->next = *p;
// *p = nou;
//}
//
//int main()
//{
// Student s;
// s.cod = malloc(strlen("231") + 1);
// strcpy(s.cod, "231");
// s.medie = 8;
// Nod* prim = NULL;
// functie(&prim, s);
//
// printf("%f\n", prim->st.medie);
//
// int v[] = { 10,20 };
// int* pv = v;
// printf("%d,%d\n", v[0], pv[0]);
// ///pointer constant la int
// int i = 7, j = 9;
// int* const pi = &i;
// printf("\nAdresa(pi) = %p, Continut(pi) = %p\n", &pi, pi);
// //pi = &j; // rescrierea zonei de memorie pi nu este posibila, fiind pointer constant
//
// int i = 7;
// int const* pint;
// pint = &i;
// printf("\nAdresa(pint) = %p, Continut(pint) = %p\n", &pint, pint);
// //*pint = i + 5;
// i += 5;
// printf("\nContinut(i) = %d\n", i);
//
//
// const int* const pint2 = &i;
// printf("\nAdresa(pint2) = %p, Continut(pint2) = %p\n", &pint2, pint2);
// //*pint2 = i + 5;
// //pint2 = &j;
// //printf("\nAdresa(pint2) = %p, Continut(pint2) = %p\n", &pint2, pint2);
// //i += 5;
// //printf("\nContinut(i) = %d\n", i);
// //printf("\nContinut(*pint2) = %d\n", *pint2);
//
// int* pint3 = NULL;
//
// // alocare memorie la runtime
// pint3 = (int*)malloc((unsigned int)i); // dimensiune zona de heap in nr de bytes
//
// pint3[0] = 1; // este ok!
// pint3[1] = 2; // NU este ok!
//
// // dezalocare memorie heap
// free(pint3);
//
//}