“указатели в CPP” Ответ

указатели в c

#include <iostream>

using namespace std;

int main()
{
   int x=5;
   int *ptr=&x;
   cout<<&x<<endl;        //prints the address of the variable (x)
   cout<<ptr<<endl;       //prints the address of the variable (x)
   cout<<*ptr<<endl;      //prints the value of x(5)
   cout<<&ptr<<endl;      //prints the address of the pointer (ptr)
   
   
}
S.Y

указатели в c

/*
Here is how pointers work in a nustshell(represent | as what's
happening in the memory and / as a place in the ram):
int x = 2; | 2/0x00ef5
int *z = &x| 0x00ef5/0x00ef6 (See how the value of the pointer z
matches with the memory address of x? that's how they work!)

when you print out the pointer as *n (replace n with the var name)
it will actually look at the value
see it's a memory address
go to that memory address
and print the value originally in the memory address which is 2

Here is code:
*/
int x = 5;
int *y = &x;
cout << *y+1;
/*
the reason why i did *y+1 was so to show that after it got
the value from the memory address it will add 1
*/
The Cat Coder

Снайктер

#include <stdio.h>
int f1(int x) { return x * 2; }
int f2(int x) { return x * 4; }

int main()
{
    int (*fptr1)(int) = &f1;
    fptr1 = &f2;
  	fptr1(3);
}
Arrogant Ape

Указатели в c

int x = 2;
int *y = &x;

cout << *y;
The Cat Coder

указатели c

baz = *foo;
Elegant Eland

указатели в CPP

int *ip; // pointer to an integer
double *dp; // pointer to a double
float *fp; // pointer to a float
char *ch // pointer to character
Chaitanya R. Talware

Ответы похожие на “указатели в CPP”

Вопросы похожие на “указатели в CPP”

Больше похожих ответов на “указатели в CPP” по C++

Смотреть популярные ответы по языку

Смотреть другие языки программирования