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
-
3
votes1
answer110
viewsDoubt with C Pointers
I have a chained list, with a single variable that is the date(int). I did this function to delete by value. lista *head = NULL; void deletar(int valor) { lista *prev, *temp = head; if(temp->data…
-
3
votes1
answer81
viewstype of incompatible pointer
Hello, programming/studying the language, C, I came across the following error warning: initialization from incompatible pointer type [-Wincompatible-pointer-types] int *ponteiro = &x; Being the…
-
3
votes1
answer60
viewsIn a chained list structure, why is a pointer to the node pointer used?
When reading my teacher’s slides I was left with a question regarding this structure: struct node { char item; struct node *next; }; typedef struct node Node; typedef node *Lista; It wasn’t clear to…
-
3
votes2
answers60
views -
3
votes1
answer148
viewsSet the array pointer within a function
I am trying to write a function that assigns an integer or a list of integers to a pointer, depending on a parameter. But the assignment doesn’t work within it, just outside: void retorna_algo(int…
-
3
votes1
answer37
viewsI cannot print, in the main function, values from a vector created in another function received by a double pointer
The following source code is the miniaturization of a larger problem I’ve been working on for two days that I can’t solve the problem. I need to print the values of the vector generated by the…
-
3
votes1
answer113
viewsHow to set a pointer as the default parameter in C++?
I am "programming in C", but compiling using the extension .cpp and the g++ to have some facilities. My goal is to make a program that receives a starting salary and calculates the final salary…
-
3
votes1
answer511
viewsError printing struct member: request for Member in Something not a Structure or Union
I have the following struct: typedef struct{ int Numerador ; int Denominador ; } TNumeroRacional ; In this function I ask the user to insert 2 numerators and denominators to form 2 rational numbers.…
-
3
votes1
answer56
viewsQuestion about address in the pointer mémoria
I put a Cout in the way insertRight to verify the memory addresses of node1 (of the variable itself and not of what she keeps) and to my surprise the addresses shown repeated several times, as shown…
-
3
votes1
answer125
viewsWhere does the memory space required for each element in a C string array come from?
In C, you can group a set of string's, which are arrays of char's within a array without having to define 2 dimensions for this? That’s why you use a array pointer char's and simply defines the…
-
3
votes3
answers40
viewsHow to turn a 2D Array into 2D Pointer in C
It is possible for a function to receive as a parameter a reference to the address of a two-dimensional array (matrix) static, and from the pointer to access the elements of this matrix. In the…
-
2
votes3
answers346
viewsHow to make a polymorphic pointer with the this pointer in the parameter?
For example, in Qt (correct me, if the logic is wrong, I haven’t touched Qt in a while), you can do this: QLabel label = new QLabel(this); Now let’s suppose: #include <iostream> class…
-
2
votes2
answers306
viewsDoubt in Struct + Pointer in C
Considering the code below, I wonder why the second printf of the Lealuno procedure does not print correctly? #define MAX 3 typedef struct aluno{ int matricula; float notas[2]; } Aluno ; int t=1;…
-
2
votes2
answers4833
viewsHow to receive a char pointer via keyboard in C/C++?
How do I receive a pointer from char keyboard?
-
2
votes0
answers129
viewsPointers to Functions
I’m facing a small problem with function pointers in a program for Microchip Pic Series 18 microcontrollers. The code displays the prototypes of two functions involved in the problem and a call to…
-
2
votes1
answer1393
viewsVector struct and pointers
I have to pick up data (name and phone) of some people in a struct, then store them in an array, all this for a function/procedure. At the time of printing comes out some strange characters. I’m…
-
2
votes2
answers503
viewsWhat is the error in this Code:
I’m trying to compile this code,do use head C but it’s returning me errors #include <stdio.h> void go_south_east(int* lat, int* lon) { *lat = *lat -1; *lon = *lon - 1; } int main() { int…
-
2
votes1
answer453
viewsWhat does the error mean: realloc(): invalid Pointer: 0xb78094d8?
My program, whose code is further down, has shown the following error: I don’t understand because I have too much memory on my PC, and all the compiler sites have the same problem. *** Error in…
-
2
votes1
answer451
viewsObject and pointer allocation
How do you allocate a pointer, which points to a class, and an object? Is there a difference? Size, etc
-
2
votes1
answer408
viewsQuery vector from one table to update another in C
Hello. I’m new here and I’m not even sure I was objective in the title. But come on. I’m almost done with my final C Algorithms project, and I’m unable to update one item from one table with…
-
2
votes2
answers704
viewsPointer operators passing by reference
I’ve been studying some codes I found on the Internet, and one of them used a prototype implementation as follows: void changeMode(Mode &m){ m.loop = true; m.quit = false; } See that function…
-
2
votes2
answers189
viewsPassing by reference in C
In the case of language C, when we want to pass a variable by reference we need to pass its address to the function, I have a question in this case. Take the example: int main(){ int *a; *a = 5;…
-
2
votes1
answer266
viewsIs this Bubble Sort correct?
People I’m reading book "Programming Principles and Practice using c++ (2nd Edition)" from C++ creator. There is an exercise there at the very beginning talking to do a program that sorts the data…
-
2
votes3
answers82
viewsShould I allocate the member of the date structure as well?
Assuming the following structure: typedef struct lnode{ struct lnode *next; void *data; int id; }Lnode; Let’s say I want to keep one Lnode in the heap: Lnode *exp = malloc(sizeof(*exp)); I must now…
-
2
votes1
answer49
viewsKeeping names
I want to allocate a string within any structure that I can search for these strings after. I need to enter a condition to end the name insertion. I’m thinking of a structure that runs until the end…
-
2
votes2
answers295
viewsProblem with malloc
People, doing a small program that given any number, enter a function that divides the number into a vector and returns the number of decimal places (number of positions) that the vector has. In all…
-
2
votes2
answers168
viewsPHP - Foreach auto tuning
During development, it is often the case that a request is made to the database, in which the returned data comes in array, sometimes it is necessary to perform a foreach to adjust these data or…
-
2
votes2
answers208
viewsProblem with threaded list pointer offset
I’ve had a problem with the shift of pointers in my code for a few days now. I try to make that if the point of my object on the screen is greater than a value, offset this object from memory, but…
-
2
votes1
answer153
viewsRemoval item in chained list C
Guys I’m having a very annoying little problem, I’m implementing a simple A* . When I move the already checked item to the closed list and move the item from the open list, it is giving undeclared…
-
2
votes2
answers886
viewspointer casting
Guys , I can’t understand why casting between pointers has some impact on the code or just to make the code readable as for example this line of a function: void* getPhysicalAddress (pdirectory*…
-
2
votes1
answer3201
viewsHow do I know the address of each vector position in C?
I’m having trouble knowing the vector address and address of each vector position. #include <stdio.h> int main(){ int vec[]={52,13,12,14}; printf("Endereço de vetor %d",&vec);…
-
2
votes1
answer1889
viewsBreak line when typing entries
I have a vector of structs with 10 people and I want my registration function to receive only one person at a time. In the terminal, the register of the first person is made correctly but then I get…
-
2
votes1
answer142
viewsData Structures - List Differences
Please would like to know the real difference between these structures below: typedef struct { int info; struct lista * prox struct lista * ant; } tipo_lista; and that: struct noCliente { int…
-
2
votes2
answers463
viewsStruct definition in C
Hello, my teacher has made the following definition of some structs for a list code in data structure, but unfortunately I cannot understand the definition of each struct itself. typedef struct{ int…
-
2
votes1
answer242
viewsHow to access a pointer within a pointer structure
I know that to access a normal variable within a pointer structure I can use this syntax: struct teste { int valor; int *aponta; }; struct teste testando, *testado; testado = &testando; testado…
-
2
votes2
answers340
viewsRefection return in C++
I cannot understand what the following function returns. int * begin(){ // return &this->data[0]; } Does this function return the address of a reference? I didn’t understand it very well.…
-
2
votes2
answers455
viewsCalculate memory address by pointer arithmetic
Suppose the elements of the vector v are of the type int and each int takes 8 bytes on your computer. If the address of v[0] is 55000, what is the value of the expression v + 3?…
-
2
votes1
answer1026
viewsDoes the scanf record string on pointer that does not have a defined size?
I’m trying to understand how the strings in C. I noticed that even not defining in any part of the code any limit for the vector TextoUm[] (which follows in the code below), the function scanf can…
-
2
votes2
answers198
viewsPointer changes the value within function in C++
I have the task of creating four functions that do multiplication, division, sum and subtraction between two numbers given by the user. The operation to be performed must be chosen through the * / -…
-
2
votes1
answer76
viewsWrite member access to a pointer structure instead of using the "->" operator
How would you write this assignment: p1->caracter='B'; otherwise using * instead of ->?
-
2
votes1
answer59
viewsWhy am I only able to manipulate files with pointers?
In the statement I always have to put FILE *Arq; If I put it without the * it presents an error. Why?
-
2
votes1
answer107
viewsPointer arithmetic in C
I am doubtful in a way to know the length of a vector without using sizeof: int n = *(&arr + 1) - arr; It is known that: arr is the type int ( * ) and (&arr + 1) is the type int ( * )[size].…
-
2
votes2
answers1641
viewsPass pointer pointer as argument for a function
I want to create an array using pointer pointer, but I’m having difficulty passing the parameters. First I dynamically allocate the matrix using a function. And then I read. The program compiled,…
-
2
votes1
answer95
viewsC++ language standard for pointer
I’m starting studies on C++ would like what is the language recommendation (market standard) to reference a pointer. ex: l->propriedade; or (*l).propriedade; I believe there’s no difference in…
-
2
votes1
answer401
viewsIs it possible to access the address of a C function?
It is possible to access the address, literally, of some function and C and also store in some variable of the main(), etc..? int f1() { }; int main() { int *ponteiro; ponteiro = &f1;…
-
2
votes1
answer499
viewsHow do I resolve struct statement Warning?
I’ll send the code and the warnings that GCC is reporting. I must ignore warnings? The warnings are related as the passage of struct for the job Inserir();: #include <stdio.h> #include…
-
2
votes1
answer210
viewsMake a parameter change the value of the variable with pointer
It is possible to work with pointers in JS, if yes, how do I do this? In the example below the goal is to make the variable str stay with the value: "worked :D" var str = "teste"; function…
-
2
votes1
answer76
viewsWhy is the result of this mini program 2?
Why the result of this mini program is 2? #include <stdio.h> #include <stdlib.h> int main() { int *P = (int *)malloc(10*sizeof(int)); for(int i = 0; i < 10; i++) { P[i] = i*10; } int…
-
2
votes1
answer59
viewsPointers in college
I’m studying pointers and this is a code used as an example that’s in the material given by the college. I went to replicate this code on my machine and the output is different from the material.…
-
2
votes1
answer737
views