int x = 5;  // x = 5;
int* p = &x;  // p is memory address of x;
int y = *x;  // y = 5;

*p = 10;  //x = 10; y =5#include <iostream>//For those unaware, the lib "iostream" stands for input output stream and is used mostly for stuff like cout or cin.
//int main() is the main function which will run upon running the exe file.
int main() {
	int x = 10;//The variable we are looking to point too
	int* xptr = &x;//using "&" you get the momory location of the variable x and you are telling xptr to point to x's location.
	std::cout<<xptr<<std::endl;//prints to location it's pointing too
	std::cout<<&x<<std::endl;//If you did it correctly it will output the same thing as xptr
	std::cout<<*xptr<<std::endl;//It will print the value(10) of the variable its pointing too. this is called derefrencing
	std::cout<<x;//It will print 10.
	return 0;
}Pointers are datatypes that point to a value of another
variable using its memory adress. Pointers are declared as following:
int* pointer;

The value of pointers is the adress of the variable. When someone
wishes to adress the value behind the adress, he can do it like this:
*pointer = newValue;

The *-operator (dereference operator) can also be read
as "value pointed to by". The example above could in that way be
read as "Value pointed to by pointer is now newValue".
Note that the asterisk (*) used when declaring a pointer only
means that it is a pointer (it is part of its type compound pecifier),
and should not be confused with the dereference operator.
  
You can assign the adress of variables to pointers:
int foo1 = 24;
int* pointer = &foo1;

The &-operator (adress-of-operator) can be read as "adress-of".
Therefore the line with our pointer declaration can be read like
"int-pointer with name pointer has now the value of the adress of foo1"
int myvar = 6;
int pointer = &myvar; // adress of myvar
int value = *pointer; // the value the pointer points to: 6#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)
   
   
}
type *ptr;   // Declare a pointer variable called ptr as a pointer of type
// or
type* ptr;
// or
type * ptr;  // I shall adopt this convention#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);
}#include <iostream>

using namespace std;

void increment(int *n){  		//declare argument of the functon as pointer
    *n+=1;
   cout<<"In function: "<<*n<<endl; 
}

int main()
{
   int x=5;			
   increment(&x);		//passing the address of the variable to the function
   cout<<"In main: "<<x<<endl;
   
}
//why do we use pointers:
1)pass values by refrence to a function
2)return multiple values from a function
3)use pointers in combinational with arrays
4)dynamic memory allocation
5)use pointers in a base class in order to access object of derived class (Smart pointers)int x = 2;
int *y = &x;

cout << *y;/*
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
*/

C相关代码片段

openGL create shape

script to check program running and restart

printf("")

Rewind to a commit Git

mouse click for colab

how to remove newline in the end of fgets string

fit text to conatiner flutter

gorm string array

js observe url change

clock skew detected makefile

time() function in c

worst fit code in c

first fit code in c

roem evaluation pyspark

calculator c

safet algorith im c

c copy char*

jfug function

soil moisture sensor interfacing with ESP32

flutter sidebar menu example

access images in c panel htaccess file

c include header file in the folder aboce

c include libray

gcc name output file

C data link escape char

How to type DLE in C

vscode Ctrl+d undo

C[strtol] func

pointer c++

power in c

sort three numbers

strip in c

c time duration

overleaf itemize a b c

route groups

itoa c code

queue in c

'wsgirequest' object has no attribute 'get'

c copy file

how to print array data in html using javascript

hello world program in c

how to compare a variable with a string in c

c print array

c rand range

exponents without pow c

how to reversed number in c

c random number with range

pthread mutex destroy while lock

pthread init mutex twice

insert c or p

woocommerce align add to cart buttons

vscode fold all code when open file

commit github non funziona

makefile both c and c++

scanf with space

c macro variable arguments

c printf format

check if prime c

read file line by line c

c use define in string

pattern program in c

Write the code in C to implement selection sort

c program of Goldbach conjecture

otput only one decimal point in c

trim string c

tokenize string c

firebase message in app doesn't work

implementing stack using linked list

esercizi semplici con le funzioni in c

array to linked list in c

sorted array to bst implementation in c

doubly linked list insertion in the middle

arch distro

distance vector routing algorithm

implement typedef with arrays

c exit vs _exit

explain in simple with c code

convert matrix to lower triangular matrix

Addition and subtraction of matrix

Transpose of a matrix