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
-
0
votes1
answer40
views`System.Nullreferenceexception` in C
Running the following code shows the error System.NullReferenceException in function call SubString #include <stdio.h> #include <stdlib.h> #include <string.h> // // Implementado o…
-
0
votes1
answer56
viewsSIGSEGV error in using a pointer
I have the following problem: I am creating a pointer and allocating memory in it, passing its reference to function, but when I read it in the function happens the error reported in the title.…
-
0
votes1
answer332
viewsManipulating list<int> in c++
My Class class Grafo{ int numeroVertice; list<int> *arestas; public: Grafo(int vertices); int addVertice(int quantidade); void addAresta(int verticeOrigem, int verticeDestino); void…
-
0
votes1
answer2690
viewsProgram Received Signal sigsegv Segmentation fault
I made the code in C of the statement: Develop a program that simulates a ticketing system for a airline. The company has no flights, where in each of them there are a available seats. The first m/2…
-
0
votes1
answer162
viewsRuntime error in C
Well, it’s compiling everything ok, however, when I print out the elements of the entire tab matrix[8][8], which is a member of the checksum structure, the compiler, in a way is assigning numbers to…
-
0
votes2
answers119
viewsChained List C does not insert new node
I started making a chained list program, but when I use the print function, it wasn’t printing anything, so I discovered that the LISTA after leaving the function inserts, it again has the value…
-
0
votes2
answers51
viewsHow do I point (with pointer, of course) to a string, so I can then print it?
I’ll give you an example of how I’m doing but it’s wrong and I’d like someone to help me fix that mistake. #include <stdio.h> void main() { char *p; char nome[21], outronome[21]; scanf("%s",…
-
0
votes1
answer96
viewsPointers with argc and argv
I have the following code to run on the terminal. It checks if the first argument is a '+' and then sums up the following numbers. int main(int argc, char *argv[]) { int i, soma; char oper; oper =…
-
0
votes1
answer572
viewsDecrease, increment and sum of pointers in C
Why when I try to add the last pointer to another 15 it repeats the second to last pointer and does not add the pointer *ptr_xi with 15 others? int xi; int *ptr_xi; void imprimir() printf("valor de…
-
0
votes1
answer93
viewsWhy can’t I print it?
It’s a simple code (I’m practicing pointers) It is not printing the result, the program closes... because? ;-; #include <stdio.h> #include <math.h> #define PI 3.1416 void…
-
0
votes1
answer120
viewsUsing a pointer can make my code faster?
I was told that if I work using pointers the program will be faster. If instead of using index to traverse a vector I use the pointer, it looks better?
-
0
votes2
answers242
viewsCode::Blocks does not print pointer value
I developed a C code to print the value and address of the variable x using a p pointer, but Code::Blocks does not print the values. #include <stdio.h> #include <conio.h> int main() {…
-
0
votes0
answers79
views'fscanf' changing pointer to struct in C
Good night. I was writing a program to read strings from a text file, and put these on a list simply chained in case its length was equal to 5. The problem is that the program started to not work…
-
0
votes1
answer763
viewsWarnings when compiling the program
In the code below, I need to create a structure for Point (Coordinate x and y) and create a function that creates these points using pointers. The structure was made as follows: typedef struct…
-
0
votes2
answers139
viewsIs it possible to rewrite any code that uses pointers (C#) without using pointers in Node.js?
It is possible to rewrite any code in C/C# that uses pointers in a way that does the same thing without using them? My fear is more complex codes. The simple ones I believe are not difficult to…
-
0
votes1
answer555
viewsError >> TESTE500K.c:(.text+0x8f): Undefined Reference to `INSERT' <<
Guys, I’m trying to create a list but it’s making these mistakes TESTE500K.c:(.text+0x8f): Undefined Reference to `INSERT' TESTE500K.c:(.text+0xa5): Undefined Reference to `IMPRIME' [Error] Ld…
-
0
votes3
answers281
viewsProblem with pointer and recursive function
The code is this : Node * search ( Node ** root, int mats ) { if ( ! ( * root ) ) { return NULL; } else { search ( & ( * root ) -> esq, mats ); if ( ( * root ) -> person.mat == mats ) {…
-
0
votes1
answer251
viewsPrint a queue item by removing each item from it
I’m making a program that receives a string with words separated by comma that separates these words and lines them up (Until then I was able to do it quietly), then the program has to go removing…
-
0
votes1
answer62
viewsMalloc in a string, based on the size of a FILE
int main(void) { FILE *p = fopen("matriz.txt","r+"); char *arquivo; arquivo=(char*)malloc(sizeof(p+1)*sizeof(char)); while (fgets(arquivo,sizeof(arquivo),p)) { printf(" %s",arquivo ); } }//END the…
-
0
votes1
answer663
viewsPassing pointer pointer by reference
I’m making a program where I need to dynamically allocate two matrices, so I thought I’d make this allocation into a function. I tried to do it this way, but it’s giving "Segmentation Failure".…
-
0
votes1
answer230
viewsConversion of C-pointers to Assembly
Good afternoon, I will have Assembly test and I have a question that is about pointers in Assembly. I’m trying to do an exercise, but I can’t fix it. "Consider the statements in C: int x=100, y=200;…
-
0
votes1
answer43
viewsChained list returning empty outside function
I’m trying to read data from a file .obj and insert into a chained list, I have a function to read and within it I call the insert function. When I call the function of printing the list inside the…
-
0
votes0
answers56
viewsWhat is the application of the concept of pointers for functions?
I would like a practical example for the use of pointer to function as well as a function having as one of the parameters a pointer pointing to a function; it is not necessary to show some code, I…
-
0
votes1
answer82
viewsChained list prints beyond what is inserted
I have that function verticeobj* loadverticeObj(char *fname,verticeobj *vo){ FILE *fp; int read; float x, y, z; char ch; fp=fopen(fname,"r"); if (!fp) { printf("can't open file %s\n", fname);…
-
0
votes1
answer518
viewsFiles For Structs/C Pointers
I have this little program and I’m able to save, and upload from the file to struct(not perfectly). The error is as follows: after loading the file to struct, if in the function I load the printf it…
-
0
votes2
answers83
viewsAccessing variables from a struct
I am studying C and I am doubtful in the difference of the following lines: (*depois).agora = 20 and *depois.agora = 20; From what I understand the point . has priority and the compiler would try to…
-
0
votes1
answer32
viewsSegmentation float when starting the function for the second time
I created a program in c++ to manipulate matrices,and I divided the source code into 2 files, one with functions and the other with implementation, all functions work correctly, but when starting…
-
0
votes1
answer54
viewsDimension of a vector passed by reference language C
I would like to know how I discover the amount of positions that have a vector that has been passed by reference to the function, using the language C. Example (Function prototype): int Soma (int…
-
0
votes0
answers18
viewsDifference in passing of data type by reference
Hello, I’m having doubts about how to pass determined by reference. Follow the code below: #include <stdio.h> #include <string.h> mostra_frase(char *frase){ printf("\nFrase digitada…
-
0
votes1
answer176
viewsBinary tree of search
#include <stdio.h> #include <stdlib.h> #include <string.h> struct arvore { int key; struct arvore * right, *left; }; typedef struct arvore Arvore; Arvore * alocar(int key) { Arvore…
-
0
votes1
answer68
viewsPointers in Go
I’m trying to change a String in Go using pointers, but I get one invalid operation: oculta[i] (type *string does not support indexing) The function I’m performing the change. func verifica(palavra,…
-
0
votes2
answers42
viewsWhy not print the contact variable[0]->a?
Pointers still confuse me mostly in situations like this. The idea is simple. I’m trying to create a pointer vector like struct. But I must be using some misconception of pointers because the…
-
0
votes2
answers610
viewsArray by function in C
Good morning! I’m having trouble passing a vector to void function for the sorting to be done and returned, as well, problem to pass to another void function whose purpose is to display the already…
-
0
votes1
answer697
viewsPassing matrix to function by reference
Good morning everyone, I wish in my code to leave the Main(); only with calling functions, all work is divided into small functions in the document. I want to write a matrix[3][3] in a function and…
-
0
votes0
answers30
viewsWhy does this appear when compiling? "Segmentation fault (core dumped)"
#include <stdlib.h> int funcao(int **piParametro) { …
-
0
votes1
answer211
viewsCast in void pointer
The code below was working as expected, but changed the type of info in the structure Retangulo* for void* and tried to cast anyway but I continue with the following mistake: t.c: In function…
-
0
votes1
answer800
viewsedges of an N x N matrix
I would like to know how to set the edge values of an array to -1. I tried to create an array of N+2 x N+2, and to do with one just, go through the edges, but when I put to print it displays some…
-
0
votes2
answers59
viewsProgram prints the next letter of the alphabet instead of the next char on the pointer
My program is printing the letter P instead of i, I would like to understand the problem behind this and what is wrong in my code. If I put the letter A instead of O, the program would print the…
-
0
votes1
answer114
viewsHow to create a pointer to store the address of a binary tree root and then use this address to call the root?
Iai galera, I have a problem in my code seemingly simple to solve, but I still get confused with pointers. The code is to insert each digit and operator of an entire parent expression into a binary…
-
0
votes1
answer151
viewsHow can I open a file in a void function?
I am trying to open a text file in a function int abreArquivoEntrada, and for this I am sending as parameter the type pointer FILE and the one vector of char containing the file name, within the…
-
0
votes0
answers16
viewsWhat Are C++ Pointers For?
I am studying C++ for about 3/4 weeks, and I always look for some exercises to practice and in several of these exercises I end up encountering Ponteiros. From what I know so far they store the…
-
0
votes0
answers534
viewsStructure and Pointers in C: Binary Tree
Hello, I’m trying to create a mathematical expression tree with the following logic: my expression is a string, and I have 4 character options: ( : When finding this character, my code should create…
-
0
votes1
answer421
viewsHow to dynamically allocate an array using a pointer pointer in a void function
I’m trying to allocate from were dynamic a matrix into a function void, this by sending a pointer pointer as parameter int **sigma, as follows lerArquivo(char *alfabeto, int *Q, int *Q0, int *F, int…
-
0
votes1
answer51
viewsWhy use a pointer to struct instead of the struct itself in this case?
Why, in the struct GERENTE and CLIENTE, I have to use a pointer to the struct PESSOA and not the struct PESSOA typedef struct{ char* nome; int cpf; } PESSOA; typedef struct{ PESSOA* pessoa; int…
-
0
votes1
answer66
viewsUse C++ variable in Assembly (Arduino)
I have an interesting code in this page. const uint8_t MachineCode[44] PROGMEM = { 0x25, 0x9A, 0x2D, 0x9A, 0x40, 0xE5, 0x5F, 0xEF, 0x6F, 0xEF, 0x6A, 0x95, 0xF1, 0xF7, 0x5A, 0x95, 0xE1, 0xF7, 0x4A,…
-
0
votes1
answer515
viewsPass pointer array to function
I need some help with this exercise. I did the whole exercise and runs well only that in the end gives error because of passing the address of the matrix to the function. What’s the problem here?…
-
0
votes0
answers177
viewsC - Stack Smashing Detected - How to correctly initialize a graph by adjacency list and insert edges?
I am receiving, sporadically and without having made any changes to the code or input, an error called Stack Smashing Detected. The only things I’m doing is initializing a graph and inserting an…
-
0
votes1
answer158
viewsProblem in memory displacement
Good evening everyone, I have been facing a problem regarding free() function in the Dysstroy() method, for memory offset. After inserting values in the binary tree at first I can even displace…
-
0
votes2
answers38
viewsProgram with Warning and does not perform what was requested
Good night! When I was studying for the test I’m going to take, I faced that question. However, when I performed the program, I did not realize what I did. I would like you to see my code in order…
-
0
votes1
answer825
viewsHow to implement a generic Mergesort sorting algorithm?
How to implement an sorting algorithm Mergesort generic (with function pointer and pointer void) in that capacity? #include<stdio.h> typedef struct{ inta; intb; }XPTO; void criaVetor(XPTO∗v,…