poiner in c

Solutions on MaxInterview for poiner in c by the best coders in the world

showing results for - "poiner in c"
Bianca
10 Nov 2018
1#include <stdio.h>
2int main() {
3   int c = 5;
4   int *p = &c;
5
6   printf("%d", *p);  // 5
7   return 0; 
8}
Giulia
03 Aug 2016
1int* pc, c, d;
2c = 5;
3d = -15;
4
5pc = &c; printf("%d", *pc); // Output: 5
6pc = &d; printf("%d", *pc); // Ouptut: -15
Vanessa
21 Feb 2018
1int c, *pc;
2
3// pc is address but c is not
4pc = c; // Error
5
6// &c is address but *pc is not
7*pc = &c; // Error
8
9// both &c and pc are addresses
10pc = &c;
11
12// both c and *pc values 
13*pc = c;
Emma
14 Jun 2017
1#include <stdio.h>
2int main()
3{
4    int var =10;
5    int *p;
6    p= &var;
7
8    printf ( "Address of var is: %p", &var);
9    printf ( "\nAddress of var is: %p", p);
10
11    printf ( "\nValue of var is: %d", var);
12    printf ( "\nValue of var is: %d", *p);
13    printf ( "\nValue of var is: %d", *( &var));
14
15    /* Note I have used %p for p's value as it represents an address*/
16    printf( "\nValue of pointer p is: %p", p);
17    printf ( "\nAddress of pointer p is: %p", &p);
18
19    return 0;
20}