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
-
1
votes1
answer760
viewsArrays and Pointers
Hello, how do I point to a multidimensional matrix? I know that to do this with a vector (one-dimensional matrix), it’s like this: int v[5]; int *ptr = v; I understand that very well, but with a…
-
1
votes1
answer93
viewsWhy use a pointer to that algorithm?
When I withdraw the code does not work. Why? And why the algorithm of Insertion Sort is only suitable for list of small entries, type array and list (little)? void insert_sort(int *vetor, int TAM){…
-
1
votes1
answer2251
viewsC pointers treated in python
#include <stdio.h> #include <stdlib.h> #include <locale.h> int main() { setlocale(LC_ALL,""); int *x,valor,y; valor = 35; x = &valor; y = *x; printf("o endereço da variavel…
-
1
votes0
answers90
viewsSum the diagonal of a matrix (pointers)
Can anyone explain to me what "a[i]+i" means? When i=0 the pointer points to 2. But when i=1 shouldn’t be a[1]+1 = 4+1 = 5? In practice it points to 8... #include <stdio.h> #include…
-
1
votes1
answer173
viewsError in covering from int to int*
I wanted to know why you are causing the error: Error converting int to int*' This program is only for training the use of pointers in parameters. void teste(int *t){ *t = 50; } int main(){ int x =…
-
1
votes1
answer992
viewsInsertion at the end of a chained list C
I would like to know how to go through the list so that I can add a new No at the end of it, in the case at the position no->Prox of the last in the present in the list. Here is my code: typedef…
-
1
votes1
answer8780
views -
1
votes1
answer790
viewsError: incompatible types when assigning to type 'char[200]' from > type 'char'
When I try to insert the char motorista an error appears: [Error] incompatible types when assigning to type 'char[200]' from type 'char' Code: #include <stdio.h> #include <stdlib.h>…
-
1
votes1
answer154
viewsInsert node into binary tree
How to insert a node into a binary tree? It always gives segmentation error when the code enters if (arv == NULL) struct no { int info; struct no *esq; struct no *dir; }; typedef struct no node;…
-
1
votes1
answer100
viewsError trying to grab data from a . txt file and move to a C queue?
I can open and go through the entire file the error happens when I try to point to the beginning or end of the queue, someone tell me if the pointers are correct typedef struct lista { int info;…
-
1
votes0
answers28
viewsFunction that returns more than one variable in c
I need to do a function that takes 3 floats and returns the average, the largest number among the 3 and the difference between the average and the largest. I tried to make the return by a pointer…
-
1
votes1
answer64
viewsModify >= 2D array using pointers
I would like to modify my matrix ( multiplying by 2 each of its elements) using pointers, but I don’t know why my code isn’t working... #include<stdio.h> void changematrix(int **mm,int row,…
-
1
votes1
answer234
viewsDynamically creating lists and saving their addresses (top of list)
Hi, I’m doing a college paper on Hash table and I’m having some difficulties. I will try not to complicate too much (to tell you the truth, the execution of my code helps me to understand what I…
-
1
votes1
answer1259
viewsStruct vector and char pointer
Why is this syntax wrong: #include <stdio.h> typedef struct { char* nome; char* numero; }Agenda; void adiciona(Agenda* reg, int i) { scanf("%s", reg[i]->nome); scanf("%s",…
-
1
votes1
answer3977
viewsWarning: assignment makes Pointer from integer without a cast
I did some research, but I don’t quite understand what that means and what it says about my code. I have that function cria_palavra which returns a pointer, there in the main, when I will receive…
-
1
votes1
answer717
viewsProblem with char returning strange characters
The intention is to replace all words toda for 0, however after X characters it starts returning strange values as can be observed in the comments. I think I’m handling the parameters wrong, but at…
-
1
votes1
answer100
views -
1
votes0
answers134
viewsNested Struct - Difficulty in understanding the concept
I have the following structures: typedef struct DataNode { int id; } DataNode; typedef struct Node { DataNode data; struct Node *Next; } Node; typedef struct List { int size; Node *head; } List; I…
-
1
votes1
answer133
viewsDynamically allocating text, and error in free()
I’m trying to allocate dynamically, but the error is appearing: Error in . /name. c; invalid : 0x000001c18834 My code: // FUNCAO // char *nome(text[]) { int n3 = 0; int n2 = 0; char *n = NULL;…
-
1
votes1
answer647
viewsHow to manipulate a vector of structs in an external function? Follow example
I am doubtful on a question. Follow the statement: Implement a library control system with functions to register, query, change and remove books. The attributes of a book are: Name (Book title with…
-
1
votes1
answer51
viewsWhy can’t I access the data from this struct with the dot, just with the arrow?
I allotted that struct by dynamic allocation and can only access the data idade via arrow and not by point wanted to know why? #include<stdio.h> #include <stdlib.h> struct pessoa { int…
-
1
votes2
answers91
viewsIs it possible to assign the first column of a row of a/a vector/matrix?
taking as an example a two-dimensional vector of the type char 2x2: char vet[2][2]; Is it possible to assign to the first line indices of this vector? or they work like a pointer to the other rows…
-
1
votes1
answer125
viewsWhat is the difference between char (*ptr)[20] and char *ptr[20]?
I’m studying pointers and came across these statements, but I couldn’t understand it very well. Could you help me? Thank you.
-
1
votes1
answer55
viewsFunction per parameter does not modify variables
I built a binary tree class in which I have a function bfs that goes all the way through it. As a parameter this method receives a function pointer void (*Op) (node_BT <type> *) that will be…
-
1
votes1
answer352
viewsHow to implement a copy constructor for a two-dimensional matrix in C++?
I have the following situation: a class Matriz implemented as follows: Header: #ifndef MATRIZ_H #define MATRIZ_H class Matriz { public: Matriz(unsigned int nL, unsigned int nC); ~Matriz();…
-
1
votes2
answers280
viewsProblem with pointer and array
I wanted to print the corresponding locations and values of a array using a pointer but when I ask the pointer to add the vector location to 8 (which corresponds to the 8 bits of an integer) the…
-
1
votes1
answer51
viewsI don’t understand the following structure
I’m having trouble understanding the following structure: typedef struct TipoItem{ int Chave; } Item; typedef struct TipoCelula *Apontador; //aqui temos um apontador tipo celula. typedef struct…
-
1
votes2
answers75
viewsError in Arduin (pointer to struct)
I’m trying to make the definition of types below but the Arduino accuses error of type declaration. /*Estrutura que abstrai a seringa*/ struct { int pot[7]; float nivel[7] = {0, 0.5, 1, 1.5, 2, 2.5,…
-
1
votes1
answer510
viewsHow to turn pointer into matrix
I’m doing a program that transforms a matrix into a transposed matrix. I am using 3 functions because I want to learn how to pass parameters of arrays. The function main() calls the function…
-
1
votes2
answers139
viewsHow to test if the free(); function worked correctly?
I’m creating the abstract kind of 2D Matrix data, and one of the functions I’m doing in TAD is this: int mat2D_free(TMat2D *mat) { free(mat->data); free(mat); } That is, a function to destroy the…
-
1
votes3
answers124
viewsHow can a pointer point to a function?
A pointer points to a memory address, so how a pointer is able to point to a function? If the answer is "functions also have addresses" then please give more details. And if it is possible to…
-
1
votes2
answers841
viewsProblem with recursiveness and pointers
I am struggling to resolve the following issue: Make a recursive function that allows you to sum the even elements of an integer vector, you must use pointers to traverse the vector My code is not…
-
1
votes1
answer238
viewsDoubt in a matter of C pointers
That’s the thing about: Build a function that takes two integer values a and b, returns (passing by reference) the quotient, div, and the rest division, mod, of a for b. The function must return -1…
-
1
votes1
answer171
viewsCan anyone help me assign value to the positions of this matrix with pointers?
Hello, I am doubtful about the following code, it creates a two-dimensional matrix using pointers, the command line that should assign specific value to each position of the matrix seems not to…
-
1
votes1
answer325
viewsAddress type Struct for INT
I have the following Struct: struct nodo{ int elo_a; char nick[26]; char cidade[16]; int idade; int elo_p;}; I have both struct assignments: struct nodo *variavel; struct nodo *offline; Ok, I…
-
1
votes1
answer48
viewsIf an object manipulated by a pointer is allocated in the heap, can it be collected by the Garbage Collector?
I am studying C# and I am in the pointers section. I understand that a pointer stores a memory address of an "object" (types by value and Array). The data stored by the pointer (the address) is in…
-
1
votes1
answer2134
viewsHow do I pass a struct vector by reference parameter?
(1) In the checar_poll function it is not printing the correct values I am reading in the ler_data function, it is printing a lot of numbers and random symbols. (2) If you solve the problem, how can…
-
1
votes1
answer52
viewspointer does not work in visual studio
Personal my question is simple but makes me unable to work with pointers, the variable 'y' simply does not receive the address of x in the example below: #include<stdlib.h> #include…
-
1
votes2
answers64
viewsHow to copy a string in C?
The following method I found on the internet, serves to create a string copy.: char* bin_copy_string(const char* begin, const char* end) { char* result; result = malloc(end - begin); if (result) {…
-
1
votes1
answer51
viewsNo startup error
I’m having a non-boot error, and I can’t figure out why: #include <stdio.h> int main(){ const int LENGTH = 10; const int WIDTH = 5; const char NEWLINE = "\n"; int area; area = LENGHT * WIDTH;…
-
1
votes0
answers36
viewsArray of pointers that point Functions
Good afternoon. I wonder if the code below is correct. I have a little bit of pointer difficulty and I entered this area of pointers to functions and I would like to understand more about this…
-
1
votes1
answer288
viewsI have a question about inherited default builders
I am doubtful when trying to improve a POO exercise here.. (-) = without I have the PAI class with two constructors (one is default). In the FILHO class I have two more constructors (no-default). In…
-
1
votes1
answer1212
viewsDynamic matrix as parameter in C or C++?
After hours of searching, I didn’t find anything that would answer my question, or I couldn’t understand the answer. I want to create a matrix NxN variable size. I made with pointers,but I want to…
-
1
votes1
answer99
viewsMemory pointer and allocation
I know which pointer stores memory address. And a variable stores a value. But taking into account that I have a class class player {} and create a variable player p; and an instance of a pointer…
-
1
votes1
answer118
viewsPointer problem - remove element in a binary search tree
Having some problem passing the root pointer per parameter to the function remove_node. This function is iterative, it has only one recursive call in the latter case. Therefore, it is necessary to…
-
1
votes1
answer180
viewsHow to pass a double pointer as argument and return it from C++ function
I have a function I need her to be void and that a Double Pole be returned from her by the argument. void cracking::decompose(char input[][100], int size_S, double* &Atm, int* &ID, int…
-
1
votes1
answer165
viewsPointer return pointing to a local character vector?
#include <stdio.h> char *local(void); void main(void) { char *ponteiro = local(); printf("%s\n", ponteiro); /*Saida = - (*/ } char *local(void) { char nome[12] = "programador"; char *ponteiro…
-
1
votes1
answer211
viewsPointer Statement in a struct and calling it in function
I must solve the following problem by creating a function for reading, one for calculation and using pointers. #include <stdio.h> #include <stdlib.h> #include <math.h> struct ponto…
-
1
votes1
answer65
viewsPrintar value of a struct by pointers
I want to print the "attribute" name of a "Person" type struct, but the printf returns (null) but I declare the struct name. Follow the code below: typedef struct pessoa{ char *nome; struct pessoa…
-
1
votes0
answers138
viewsPointer array in which each element is a row
Hello. I wanted to create a pointer array in which each element pointed to a supposed queue, but when I try to access the (pointer vector) -> (TAD queue) -> (vector inside the queue TAD), I…