-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpointer.c
More file actions
29 lines (29 loc) · 715 Bytes
/
Copy pathpointer.c
File metadata and controls
29 lines (29 loc) · 715 Bytes
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
#include<stdio.h>
#include<string.h>
//This I should take care
void fun(int const *ptr)
{
*((int *)ptr)=20;
/*
First we are converting the ptr to integer pointer
Then the value stored at that position is changed
If you take a close look you are changing the
value of the constant. Otherwise it is not possible.
*/
}
int main()
{
int const j=10;
int const k=50;
int const *pointer;
int a=50.55555;
fun(&j);
// This statement will create an error k=40;
//
pointer = &k;
*((int *)pointer) = 30;
printf("%d\n",j);
printf("%d\n",k);
printf("%f\n",(float)a);
return 0;
}