Most voted "pointer" questions
The tag can be used for the concept applied to any language. A pointer is a type of data that "points to" another value stored in memory using its address.
Learn more…481 questions
Sort by count of
-
58
votes5
answers8000
viewsWhat is the difference between pointer and reference?
One of the first things I learned about Java is that this language "has no pointers, only references", followed by some generic statements about how the first is complex and the second is simpler.…
-
45
votes6
answers2425
viewsArrays are pointers, right?
After all, in C, an array a[] becomes a pointer *a? If not, what are arrays? What are the differences between them? How arrays work internally?
-
35
votes2
answers998
viewsA C compiler can generate a 64-bit executable where pointers are 32-bit?
Most programs fit well into address space of less than 4GB, but in some cases the program may need to use new processor features/instructions that are only available on x64 architecture.…
-
33
votes4
answers41801
views -
25
votes2
answers1393
viewsWhen should I choose whether or not to use a pointer when creating an object?
In C++, I’m used to seeing objects being created through the operator new, which is when the object is referenced by a pointer, thus: MinhaClasse *mc1 = new MinhaClasse(); This form seems to me the…
-
21
votes3
answers4426
viewsIn practice, what is the use of C-pointers?
Recently I have been studying the language and so far I have not identified practical utility for the use of pointers. I understand how it works very well, but nothing more.
-
20
votes3
answers523
viewsWhy does C array[6] equal 6[array]?
Note: Question I saw in ONLY in English, but I found it interesting to put here (because we still don’t have many questions of C): Because in the C language, this code prints "true"? #include…
-
18
votes2
answers22927
viewsWhat is the meaning of the "&" (commercial) operator in the C language?
I am putting together a workbook in C and I am looking for a clear way to explain this operator to the reader, and I believe that this question will help the people who are starting. Take an…
-
17
votes1
answer23130
viewsHow to pass a function as parameter in C?
I wanted to know how the function passed by parameter as it happens in pthread_create (thread,atributo,rotina,argumento);. On the field rotina a function is placed in void*.…
-
17
votes4
answers793
viewsSimple Teaching of Pointers
I’m a sporadic programmer, and whenever I need to use pointers, I realize I’ve forgotten how to use it, and I have to work hard to learn everything again. Does anyone have any simple didactics to…
-
17
votes4
answers359
viewsOutput a C code with pointers
I need to understand what each of the values printed on the screen means by the following code: #include<stdio.h> int main() { int i=5; int *p; p = &i; printf("%u %d %d %d %d \n", p,…
-
16
votes2
answers17517
viewsReal difference between point operator (.) and arrow operator (->) in C?
What is the real difference between the two operators. I know the operator (->) is used when the variable is a pointer, and that it is equivalent to (*ptr).membro. Well, if I declare a pointer of…
-
15
votes2
answers6497
viewsWhat is pointer to pointer?
How to use it pointer to pointer? I find it hard to tell what it is memory address and memory value when I try to use pointer to pointer, it seems mysterious to me. Someone could give me an…
-
15
votes2
answers1239
viewsWhat is the difference between *var++ and *var += 1?
I’m writing a feature with the signature: int increment(int *val). My intention is to receive an entire pointer, increase its value in 1 and return that value. The body of my function was as…
-
14
votes2
answers2384
viewschar[] or *char malloc?
What difference in C between char text[10] or char *char = (char *)malloc(10*sizeof(char)); What advantage of using malloc on a pointer?…
-
14
votes1
answer1711
viewsIs there a pointer in Javascript?
I was programming and I found something interesting but I was left with doubt in a situation. I created an object and referenced it so: a = {a:1,b:2} And then I created another object and assigned…
-
12
votes3
answers10773
viewsIs it possible to use Java pointers?
In the C language we can use ponteiros as follows: int *ponteiro, teste; ponteiro = &teste; And in Java there is some alternative?
-
12
votes2
answers1470
viewsWhat are the pointers?
I’ve come across this in several languages, mainly C and C++, but I’ve never understood what it is, how it’s used, and why it exists. I found out unintentionally that it also exists in C# and it’s a…
-
11
votes3
answers3123
viewsformat ľ%d' expects argument of type ěint', but argument 2 has type ěchar *' - What is it? How to tidy up?
Code: #include <stdio.h> int main(void) { char caractere, *caractere_ptr = &caractere; printf("Caractere: foi alocado %zu byte\n", sizeof(caractere)); printf("Endereço: %d",…
-
10
votes3
answers42472
viewsError Segmentation fault (core dumped)
I’m getting the following error message in my code: Segmentation fault (core dumped) Another thing is, when I performed the same function operation preenche in the main, using ficha.name in place of…
-
10
votes2
answers925
viewsHow do C’s hands work?
first What is the difference between declaring: char* s and char *s? 2nd It is always necessary to use the function malloc when declaring a inter? Example: char* s = malloc(sizeof(char)); //ou…
-
10
votes3
answers540
viewsWhat kind of smart pointer to choose?
How to know what kind of smart pointer to use? And what’s the difference between them? Example: std::unique_ptr<MinhaClasse> mClasse(new MinhaClasse) std::shared_ptr<MinhaClasse>…
-
10
votes2
answers930
viewsPrototype functions in C/C++
What kinds of functions are these? What can these prototypes do? /*1*/int func ( int (*x)(int,int) ) /*2*/int func ( int x(int,int) ) /*3*/int func1 ( int(fn)() ) /*4*/int func2 ( int(*fn)() ) Is…
-
9
votes2
answers4823
viewsHow to access a specific RAM location by address?
I’m starting to study C/C++ pointers and it was something that caught my attention by the robustness and the range of possibilities. However, I can only access memory positions by assigning to my…
-
9
votes1
answer216
viewsPointer variable is declared null, but member function performs normally
Below follows an example of the code I’m trying to execute. //main.cpp #include <iostream> using namespace std; class A{ public: A(){} ~A(){} void teste(){ cout << "Teste" << endl;…
-
9
votes1
answer542
viewsWhy do we use parentheses in a pointer statement?
What is the difference between these two statements? int* array1[10]; int (*array2)[10]; Why are there parentheses in the second?
-
9
votes1
answer90
viewsWhy are there two const in the variable statement?
I can do it: const int* const objeto = &x; Why are there two const? What is the function of each?
-
9
votes2
answers562
viewsWhy assign NULL on a pointer after a free?
I see in many codes assign NULL on a pointer just after a free, guy: free(p); p = NULL; What good would that do?
-
9
votes2
answers1223
viewsWhy don’t you need the `&`in the `scanf();`?
I learned that the variable always has to have &, but in this example you don’t need and still show the result. Why you didn’t need the & in the scanf();? #include <stdio.h> int…
-
8
votes2
answers3219
viewsC++ - Size of an array pointer
I have an array: char *exemplo[] = {"item1", "item2", "item3"}; And a function: void myFunc(**myArray) { } So, I want a function that returns the size of this array that I passed as parameter. For…
-
8
votes1
answer410
viewsMatrix parameter passing error
I am trying to understand the function of pointers for an array. For this, I have elaborated the small program below. I made some mistake, because, in the indicated line, error is occurring…
-
8
votes2
answers193
viewsHow does a variable point to a pointer?
Reading this answer on pointers and arrays in C, there is the example below where the variable ptr points to the first element of this array. int array[42] = {42}; int *ptr = a; How this pointer…
-
8
votes1
answer460
views -
8
votes3
answers2490
viewsWhat are the differences between pointer and reference in c++?
This question is a specific version for c++ of the question: What is the difference between pointer and reference? In practice, what are the differences between a pointer and a reference in C++? I…
-
8
votes2
answers1802
views -
8
votes2
answers271
views -
8
votes1
answer148
viewsAccess null pointer is not generating error
Testing the code below, I noticed a strange behavior. It’s working when it shouldn’t. The correct in my view was to give a segmentation failure and abort, but it seems that the compiler is doing…
-
8
votes3
answers230
viewsWhy are methods that operate pointers insecure in . NET?
Reading a bit of the . NET source code I realized that some methods have a peculiar modifier, the unsafe. [System.Security.SecuritySafeCritical] // auto-generated…
-
8
votes1
answer140
viewsFunction to void pointer conversion*
Recently, I was trying to solve a problem in a program of mine in C and, by chance, I came across some answers from Stack Overflow in English which stated that converting a pointer to a function to…
-
8
votes2
answers105
viewsHow does an array of functions recognize the position of the next element?
Why do you ask: The question may seem strange, but is that I am a beginner in programming and at this moment I am studying pointers to function and in an example in the book by which study is…
-
7
votes1
answer2547
viewsWhen to use void* and auto*?
C++11 provided us with the type auto (Automatic). It can transfer type for the first time. But before it, people used to use the void*, where you referenced on the pointer. I still use void*…
-
7
votes2
answers3467
viewsHow to add two arrays of integers with pointer arithmetic?
I am doing an exercise where I pass by parameter two integer arrays already defined by the user. I need now, in a third array, to store the sum of the two received arrays, at the same positions,…
-
7
votes2
answers4418
viewsWhat does it mean to create an object with that asterisk?
Although I knew programming for a reasonable time, learning C++ with QT, I came across something I hadn’t seen in other languages. I noticed that some objects (not all) need to be created with an…
-
7
votes2
answers111
viewsAccess to specific memory points
How do I access an exact address in memory on Windows? unsigned char * mem = {??};
-
7
votes1
answer598
viewsIs it correct to return a memory address in function?
I was asked to design a function that was called, open a file. txt and return the pointer of this file, ie return a memory address. However as I know memory is only temporarily allocated for…
-
7
votes3
answers972
views -
7
votes2
answers2251
viewsSizeof() or strlen()?
sizeof() or strlen()? What’s the difference in their use on char hands? which is more appropriate?
-
7
votes1
answer219
viewsStart structure pointer with an address?
I wonder if it is possible to start this structure type pointer with an address, without needing to point to another variable, or allocate memory. typedef struct{ char nome[20]; int idade; }pessoa;…
-
7
votes1
answer275
viewsWhat is the purpose of while(*variable) and if(!*variable) in the statements "while" and "if"?
In Code Review there is a implementation of a simply chained list that I am using. However, in the reply of one of the users, he made some modifications to the list, and had a particular…
-
7
votes2
answers142
viewsWhat does byte* mean?
I’m studying cryptography and I took an example in AES. In the code is this byte* and even *variavel and I couldn’t understand what it meant. This is the block that uses this, quoted above: byte*…