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
answer73
viewsError pointer -Wint-Conversion ?? Int to int *
#include<stdio.h> #include<stdlib.h> int *a; int b; int main() { b = 5; *a = &b; printf("%x \n",a); printf("%d",*a); printf("\n %d",b); return 0; } In code output this error appears…
-
-1
votes1
answer54
viewsPointer cast
void *ft_memchr(const void *s, int c, size_t n) { while (n > 0) { if (*(unsigned char *) s == c) { return ((void *)s); } s++; n--; } return (NULL); } What would this be *(unsigned char *)s? I…
-
-1
votes1
answer129
views -
-1
votes1
answer83
viewspassage by struct reference does not work (Dynamic queue C)
I’m trying to implement a dynamic Fila. When I start the program (start and end = NULL), and then place to queue a value (queue function) the pointer "end" receives the new queue item, but the…
-
-1
votes1
answer63
viewsWhy can I still access a variable in the heap even after the function is over?
A while ago I learned about heap and stack, I was testing some codes when I came across a strange behavior in heap see; #include <iostream> using namespace std; void Test1(int *i[]); void…
-
-1
votes1
answer163
viewsHow to use a function to fill all positions of the dynamically allocated vector?
Good afternoon guys, I’m seeing for the first time the C language and I’m not making progress on a job. First you are asked to create a function int receive Operator() This function will request the…
-
-1
votes1
answer47
viewsDynamic allocation in wrong scope
I dynamically allotted a vector of structures with qtdeFuncionarios positions within a if, but now I need to use it within another conditional structure and the compiler accuses scope problem. How…
-
-1
votes1
answer79
viewsRead string pointer in C
This is the question: 4. Make a program that receives from the user the size of a string and call a function to dynamically allocate this string. Then the user must inform the contents of this…
-
-1
votes1
answer540
viewsOccurrence of letter in string - C
Good afternoon, My goal is to insert a string of up to 500 characters, and then read a letter. Creating, for this purpose a function that counts how many times that letter appears in the text. The…
-
-1
votes1
answer58
viewsProblem with DYNAMIC ALLOCATION with char pointer in structs
I have the following problem: I must create a program that will register an N number of students and the maximum size of each student’s name is M. I must use the following structure: struct Aluno{…
-
-1
votes2
answers38
viewsPointer+Struct (DOUBT)
Good afternoon guys, I’m learning to use pointers in struct's... so I tried to do a record exercise of nome and id very simple with a vector size for only 3 entries. I can’t find the error of my…
-
-1
votes2
answers63
viewsSegmentation failure when printing white space C
I need to do a function that returns a doorman to the first blank space found in the string. When I try to print the blank space the program accuses segmentation failure, which does not happen when…
-
-1
votes1
answer45
views -
-1
votes1
answer49
viewsHow to access, within a function, the member of a dynamically allocated structure?
I have the following code in C: #include <stdio.h> #include <stdlib.h> struct pessoa{ char nome[11]; int idade; } void cadastra_pessoa(char novo_nome[11], int nova_idade, struct pessoa…
-
-1
votes1
answer36
viewsProblem to link two structs in C
The program is about a bank, I need two structs (one of client and one of accounts), the account holder has to be linked with some client. But in the Add_account function, I am not able to make this…
-
-1
votes1
answer19
viewsArraylist of another class does not print elements
I have a main class and another class, basically I have to read a CSV file in which the first line will have the materials of a student (matematica, portugues etc). The number of materials is N can…
-
-2
votes2
answers177
viewsNear and Far pointer error in C code
Code compilation error in C, with Near and Far pointers #include <stdio.h> void main(void) { char *titulo_near = "Bíblia do Programador C/C++, do Jamsa!"; char far *titulo_far = "Bíblia do…
-
-2
votes1
answer104
viewsSyntax error using pointer
int main() { char const* path = "/bla/bla"; struct zip *teste; int *errorp; &teste = *zip_open(path, ZIP_CREATE, errorp); return 0; } It returns this error: main.cpp: In function ‘int main()’:…
-
-2
votes1
answer88
viewsWhy does a variable passed to function not keep the changed value when it exits the function?
I want the variables latitude and longitude to be updated, but only the variables lon and lat are being changed. I cannot add latitude = latitude - 1 or longitude= longitude + 1.…
-
-2
votes1
answer40
viewsI need to print a L1 line of a matrix in C
After reading L1 in main, I need to pass line A[L1] to a function and print this line Prints(A[L1]), only it gives an error saying that it does not recognize the parameter. What can it be? void…
-
-2
votes2
answers47
viewsMembers of a structure as pointers
In the code below I am trying to define a structure whose members are pointers that will be used to work with the name, email and age data, all dynamically allocated, of an employee. However, the…
-
-2
votes1
answer59
viewsPointer accessed improper data
I’m having difficulty implementing the logic of introducing new employees in the code below. When determining the new quantity and reallocating the vector based on it, the first new employee is…
-
-2
votes1
answer104
viewsSegmentation fault when returning to main C++
I am getting this error, I know it is an improper memory access error but I can’t find the error! it finishes running the wayValido(...) and when it will return from the main it crashes and gives…
-
-2
votes1
answer30
viewsHow to access the value of a pointer within a function in main?
#include <stdio.h> #include <stdlib.h> int *Notas_Baixas(float Vet[],int Total_De_Notas, int *Pont_Numero_De_Notas_Baixas){ int i; *Pont_Numero_De_Notas_Baixas = 0; for(i = 0; i <…
-
-3
votes2
answers216
viewsLoop End Error (Bug delete with char*)
1 - I have this code (Gave An Abridged, Type -1, And Then 'n' To Exit The Loop And Make The Mistake): #include <iostream> #include <cstdlib> #include <cstdio> #undef max using…
-
-3
votes3
answers83
viewsI need to do a function that passes an n * m matrix, is transformed into a unidimesional tam n *m vector
int* Vetor_Unidim(int **matriz, int n, int m){ int *vetor = (int*)malloc((n*m)*sizeof(int)); int *p; p = *matriz; int tam = n*m; int i; for(i = 0; i<n;…
-
-3
votes1
answer107
viewsI’m doing a C program, which consists of implementing the Lagrange interpolation method
I’m doing a C program, which consists of implementing the Lagrange interpolation method. Where the user enters the table data (values of x and fx, and I have to return the value of lx and px, only…
-
-4
votes1
answer159
viewsImprove the performance of a pointer method
Here’s the code working: string string_pick(string text, string tag, char caractere) { int index = text.IndexOf(tag); return text.Substring(index + tag.Length, text.IndexOf(caractere, index +…
-
-5
votes1
answer199
viewsVectors, pointers and memory storage
I need to solve an exercise where I need to use pointers, vectors and memory storage: Create a vector with n elements, and each vector position will match a pointer to a value of type float. Make…
-
-5
votes1
answer111
viewsSum with vector and pointer in C
Goal: Sum 7 numbers typed by the user that will be stored in an array, the sum must be done with a pointer. Problem: The pointer generates an wrong result, if I take the asterisk from the pointer…
-
-7
votes3
answers12254
viewsHow to initialize an array using pointers?
I need to initialize a 0 matrix using pointer to address its elements