pointers

Solutions on MaxInterview for pointers by the best coders in the world

showing results for - "pointers"
Martín
09 May 2017
1Variable is used to store value
2Pointer is used to store addresss of value
Giada
10 Oct 2017
1#include <stdio.h>
2
3int main () {
4
5   int  var = 20;   /* actual variable declaration */
6   int  *ip;        /* pointer variable declaration */
7
8   ip = &var;  /* store address of var in pointer variable*/
9
10   printf("Address of var variable: %x\n", &var  );
11
12   /* address stored in pointer variable */
13   printf("Address stored in ip variable: %x\n", ip );
14
15   /* access the value using the pointer */
16   printf("Value of *ip variable: %d\n", *ip );
17
18   return 0;
19}
Jana
13 Jul 2016
1/*
2**use of pointers is that here even if we change the value of c since the adderss is
3* of c is assigned to pc it *pc will also get modified*/
4int* pc, c;
5c = 5;
6pc = &c;
7*pc = 1;
8printf("%d", *pc);  // Ouptut: 1
9printf("%d", c);    // Output: 1
10
Filippo
17 Apr 2019
1#include <stdio.h>
2int main() {
3   int c = 5;
4   int *p = &c;
5
6   printf("%d", *p);  // 5
7   return 0; 
8}
Guadalupe
26 Apr 2020
1int* pc, c, d;
2c = 5;
3d = -15;
4
5pc = &c; printf("%d", *pc); // Output: 5
6pc = &d; printf("%d", *pc); // Ouptut: -15
Anna
30 Apr 2017
1#include <iostream>
2
3using namespace std;
4// isualize this on http://pythontutor.com/cpp.html#mode=edit
5int main()
6{
7   double* account_pointer = new double;
8   *account_pointer = 1000;
9   cout << "Allocated one new variable containing " << *account_pointer
10      << endl;
11   cout << endl;
12
13   int n = 10;
14   double* account_array = new double[n];
15   for (int i = 0; i < n; i++)
16   {
17      account_array[i] = 1000 * i;
18   }   
19   cout << "Allocated an array of size " << n << endl;
20   for (int i = 0; i < n; i++)
21   {
22      cout << i << ": " << account_array[i] << endl;
23   }
24   cout << endl;
25
26   // Doubling the array capacity 
27   double* bigger_array = new double[2 * n];
28   for (int i = 0; i < n; i++)
29   {
30      bigger_array[i] = account_array[i];
31   }
32   delete[] account_array; // Deleting smaller array
33   account_array = bigger_array;
34   n = 2 * n;
35
36   cout << "Now there is room for an additional element:" << endl;
37   account_array[10] = 10000;
38   cout << 10 << ": " << account_array[10] << endl;    
39   
40   delete account_pointer;
41   delete[] account_array; // Deleting larger array
42   
43   return 0;
44}
queries leading to this page
c 2b 2b use elemtns and save pointerwhat are pointers used for c 2b 2bwhen we create a prointer so where is created in c 2b 2buses of pointers in c 2b 2bc 2b 2b what are pointers used forsee the variable of pointer c 2b 2bc 2b 2b function pointerpointer example code in chow pointer ibn cc 2b 2b pointer tutorialhow to point to something in c 2b 2bint pointer in c 2b 2bpoiter in cc 2b 2b pointer in functionpointrs in c 2b 2boperations with a pointer c 2b 2bpointer of variable c 2b 2blearn pointers c 2b 2bwhat are pointers used for in c 2b 2bin c 2b 2b there are pointers 3f pointer use function c 2b 2bhow to store the next value of a pointer in c 2b 2bcpp pointer pointerpointer pointer comworking with pointer in cpphow to create an pointer in c 2b 2bc 2b 2b type pointeraccessing values via pointers in c 2b 2bprogramming c pointerspointer in c 2b 2bpointer to pointer in cpphow to declare a int pointer c 2b 2bc 2b 2b variable take pointer valuec pointer simple examplepointer assignment in cwhats a pointer c 2b 2bpointer c usepointer c 2b 2b syntaxhow to use pointerskom pointers c 2b 2bc 2b 2b what pointer haspointer c languageadding pointers in c 2b 2batol function in c languagepointer variable c 2b 2bwhen to use pointers c 2b 2btypes of pointers in c 2b 2bfunction pointer syntax in c 2b 2bwhat are pointers in cpppointers c programmingpointer function in c 2b 2buses of this pointer in c 2b 2breference variable vs pointers 2a in cusing pointers in classes c 2b 2b 28ptr 2bi 29 c 2b 2bwhat is 26value in chow to use pointers in cc 2b 2b pointersdifference between pointer and variablec 2b 2b poimter 3ehow to access int 2a 2ainput2 mean in c 2b 2bwhy we need pointers in c 2b 2b programming 3fpointers in c 2b 2b tutorialpointer in c programmingpointers c languagewhat is a pointer in cpointers explained c 2b 2bwhat is a pointer c 2b 2bc 2b 2b functions with pointersdoes c 2b 2b use pointersaccess pointer cpp 2a 2a in pointerspointer to value cclass and pointers in c 2b 2busing pointers in structurea c 2b 2bc 2b 2b declare pointers with new explanationcpp class pointerhow to save code into a pointer c 2b 2bpointers declaration in c 2b 2bpointer in c 2b 2b 2bwhat is a pointer cwhat is pointer in c 2b 2bptr c 2b 2bin c 2b 2b putting the 26 operator in front of a variable is how to get the address of the variable in memory how to use next in pointers in cppc 2b 2b assign a pointeris there pointers in c 2b 2bpointer in c 2c c 2b 2bpointers in c 5cpointers in cpointer cppvalue of an address in c using ppintersc 2b 2b pointers accufunction pointers cppc 2b 2b is a pointer an integer 2a in cppuse pointer class c 2b 2bstructure of pointers in c 2b 2bwhat are pointers and there use in cpppointers examplewhat do we mean by changing pointer type c 2b 2bc 2b 2b declare pointerpointers c 2b 2bwhat is pointer in cis there pointer in c 2b 2bprogramming pointersc 2b 2b have pointersare there pointers in c 2b 2blocation of a pointer c 2b 2bhow to assign a pointer in c 2b 2busing pointers c 2b 2b exaplesprogram pointer examplethe pointer address in cpointeres cwhat is pointer to character mean in c 2b 2bc language has pointerspointer function c 2b 2bhow to get the content of a pointer in c 2b 2bpointers em cpointer example in cwhat is this pointer in c 2b 2bc 2b 2b 2c pointer examplevariable vs pointerhow to access a point in c 2b 2bc 2b 2b output variable by pointerc 2b 2b pointer operationsc tutorial on pointersc syntax pointerformat of address of variables in c 2b 2bpointer and address in c 2b 2b 5bc 5d pointerspointer c 2b 2bsimple pointer program in c 26 in c pointerswhat can you use pointers for in c 2b 2bc 2b 2b variable and code memory locationpointer in c examplehow to declare pointer c 2b 2bwhat does 26 mean in pointer c 2b 2bhow to use pointers c 2b 2bcpp pointer to intuse pointers c 2b 2bc 2b 2b pointer 2b 2bprogram with pointers in c 2b 2bassign pointer to another pointerc 2b 2b assign value to pointer memorywhat to include c 2b 2b pointersclass pointer in cppwhat are pointers c 2b 2bpointer c 2b 2b de pointer itwhat is a pointer in c 2b 2bpointers c 2b 2b explainedpointer to an integer c 2b 2bpointers in c pointers 2c c 2b 2bc pointers explainedint 2a 2a p use c 2b 2bc 2b 2b how to declare a variable using pointerwhat is an lvalue in cc 2b 2b pointers explained 2a in c 2b 2bhow to create a pointer in c 2b 2bpointer in c 2b 2b 26function pointer syntax c 2b 2bc 2b 2b pointer examplethis pointer use in c 2b 2baddress cppdeclare ptr 28 29 c 2b 2bprogramming using pointersdefine a pointer in chow to make a pointer in c 2b 2bwhat is pointers in oopsassign value to ptr c 2b 2bc 2b 2b pointerfor c 2b 2b int pointerget address of varialbel c 2b 2bdo c 2b 2b have pointersuse of this pointer in classe in c 2b 2bpointer on cc 2b 2b declare a pointerc pointrptr variable in c 2b 2bwhat are pointers in c 2b 2bpointers in function in c 2b 2bc 2b 2b pointers for beginnershow to make in address in c 2b 2b store a valuewhy use pointers in c 2b 2bread variable from pointer c 2b 2bset pointer c 2b 2bwhy we use this pointer in c 2b 2busing a pointer in c 2b 2bpointer c 2b 2bhow to use pointers in cpppointer value c 2b 2bpoint pointerwhat is the use of this pointer in c 2b 2bwhy are pointers useful in c 2b 2bpionter holding a value in cppc 2b 2b what are pointersint pointer c examplec 2b 2b what is pointersare pointers necessary in c 2b 2bpointers c 2b 2b 2baccess value of a pointer c 2b 2bdefine pointersc 2b 2b set pointer valuec 2b 2b pointer declaration 28p 2b1 29 3edisplay c 2b 2bhow to declare a pointer in c 2bpoiner cpointers definitiondifference between pointer variable and reference variablepointer example c 2b 2bc 2b 2b tutorial pointerspointer of pointerspointer in cppc 2b 2b what is a class pointervariable vs pointer variablewhat are pointerspointer to pointer c 2b 2bc 2b 2b 2ac 2b 2b declare pointer valirablepointer example in c 2b 2bpointers in cppcpp pointersc 2b 2b poimter 3fpointers examples in cpointer in c 2b 2b 25how to acces the value using pointer in c 2b 2bdoes c 2b 2b have pointerspointers cpp point toa pointer to an intc pointerc 2b 2b how touse pointers 26 c 2b 2bpointer in c 2b 2b examplewhy are pointers useful c 2b 2bpointers programminghow pointers work in cwhat are the pointers in c 2b 2bcreate a pointer to a variable in c 2b 2bc langauge have pointerspointers in c 2b 2b explainedc pointersc 2b 2b pointer totourialhow to assign a pointer to another pointerfunction pointer c 2b 2bpointer in cwhat are c 2b 2b pointers actually 3fc 2b 2b int pointerhow to use c pointersdefinition of pointers c 2b 2bwhat is the use of pointers in c 2b 2b 27pointers inc 2b 2bc 2b 2b set values to pointerc 2b 2b why is this a pointerdereference pointer c 2b 2bwhen a pointer is cout is a location 3fc 2b 2b set the value of a pointerhow to assign value to a pointer in c 2b 2bc 2b 2b pintget po c 2b 2bpointersin c 2b 2b the get and put pointer show the location of the next bit or bytepointer with syntax and example cpp function pointer 2a 2a in c 2b 2bhow do you declare pointer varibale in c 2b 2bwhat is poiter in cc programming pointerspointer cwhy we use pointers in cppsyntax of this pointer in c 2b 2bpointers meaningsetting a pointer equal to another pointer cillustration of pointers in c 2a in c 2b 2bwhat is pointers c 2b 2bhow important are pointerswhy do we use pointers c 2b 2bpointer syntax in c 2b 2bwhat are pointers in c 2b 2b programming 26 pointers c 2b 2bc 2b 2b int with starthings not possible with pointer c 2b 2bwhat can pointers be used for in c 2b 2bpointer variable in c examplewhat do pointers doc program how to find the earlier pointerwhen should i use pointers c 2b 2busing new defines pointer c 2b 2bc 2b 2b pointers are always passed byworking with pointers in c 2b 2bhow to define pointerspointers in c programmingclass function pointer c 2b 2bhow to get the value from address of pointer in c 2b 2bhow to create a variable with a name of its pointer c 2b 2bwhat is a pointer variablec 2b 2b pointers to ppointers in c languagepointers incterniarry in cspecial pointers in c 2b 2bhow to use 2a 2a 2apointer in c 2b 2bhow to use pointer function in class in cpppointers in programminga pointer in c 2b 2bwhats are pointers in c 3f 2fc 2b 2b sample from pointerwhich of the following will output the memory address for a 3f c 2b 2bpointers inn c 2b 2bc programming what is ptrc 2b 2b what is a pointerhow to declare a pointer in c 2b 2bwhat is a c 2b 2b pointerconcept of pointers in cdifference between variable and a pointerare pointers in c and c 2b 2b class with pointer c 2b 2bwhat is this pointer 2apointer in caddress of pointer varoable in c 2b 2bsetting a pointer equal to another pointerc 2b 2b pointer 3epointers in c programming with examplespointers are ofeveything about pointers in c 2b 2bhow to output a pointer c 2b 2bdeclare pointer c 2b 2bwhat is the content of 2ap cppprint int 5b 5d c 2b 2b using pointerhow to write to a pointer in cc 2b 2b pointer syntaxwhat is this pointer 3fpointer in oopc 2b 2b set value of pointerhow to make a pointer to this c 2b 2bfunction pointers c 2b 2bwhat is the difference between pointer and variablepointer 5bi 5d cpointer definition in cc 2b 2b memory pointerscpp constructor pointerpointers vs reference variablesusing pointers in c 2b 2bc 2b 2b this pointerpointers baasics in c 2b 2bassign value to pointer c 2b 2bfrom pointers to integer c 2b 2bpointers meaning in programmingthis pointer c 2b 2bc 2b 2b get pointeradd variable at certain memory adress c 2b 2bpointer vs pointer variablefor using pointer c 26 in c 2b 2b pointerexplain pointers in c how it is declared and usedpointer address in cwhy do we use pointers in c 2b 2bc 2b 2b pointer notationdeclare a pointer cpppointers cpointers basicshow to input a pointer in cppwhat can you do with pointerscpp pointerwhat is pointers 21 21 pointer cdisplay the address of a variable in c 2b 2bthis pointer in c 2b 2bpointers program c 2b 2b access pointerstype of pointers in c 2b 2bwhat is the value of a pointer when you set it to a pointer c 2b 2b 5cc pointer contentsin c 2b 2b what is a pointerc 2b 2b declare pointer to inthow to declare a pointer in cppc 2b 2b operator used to access the memory address of a variablec 2b 2b when to use pointerspointers in c 2b 2b is stored in which memoryc 2b 2b pointers exampesint pointer c 2b 2bpointers in c 2fc 2b 2b coursehow to make a pointer c 2b 2baddress to an address c 2b 2bdepointer c 2b 2bis this a pointer in c 2b 2bpointers vs simple variablesprograms on pointers in c 2b 2bhow to use pointer in cpointers in c 2a 2a 2awhat is class pointer in c 2b 2bc pointer examplespointers c 2b 2b definitionc 2b 2b pointervariable with pointers c 2b 2bpoiner in c 2b 2bwhich c 2b 2b pointer to usepointers cpppointer in c 2b 2b meanasterisk c 2b 2bwhat does the int do in pointers cpppoiters in cppexample of pointerdo you need to unassign pointers c 2b 2b 26 pointers in chow to use pointers in c 2b 2bwrite a c program to illustrate the concept of pointers and functionsint 2aa c 2b 2breference variable vs pointerpointers in c 2b 2b 26 oin c 2b 2bc 2b 2b maths with pointershow to store memeory address in varaible c 2b 2bwhat are pointers in chow to work with pointers in c 2b 2bpointers