Questions tagged as 'ponteiro'

1
answer

Pass pointer as C ++ function parameter

Good morning, I have the following problem: I have a class that represents a List, and from it I have created three objects (I do not know what happens) list1 (5), list2 (5), list3 (10). template<class T>class Lista{ private:...
asked by 11.06.2014 / 14:44
1
answer

Malloc 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 matrix cont...
asked by 13.12.2018 / 14:53
1
answer

Accessing methods of a class in a vector of pointers

Right, I have a Package class with a public method double calculate_cost (). I need to create a std::map<string, std::vector<Package*>> in which I can iterate through the vector and save the return of the calculate_cost () m...
asked by 05.10.2018 / 23:37
1
answer

Problem with Segmentation fault with integer pointer

The program below attempts to reproduce a cellular automaton model. When I use "n" (number of cells) in excess of 65K, the program returns Segmentation fault. I tried to "print" some text in several places of the code, but it does not execute...
asked by 27.09.2018 / 21:09
1
answer

Warning: assignment makes pointer from integer without a cast

I did a search but I did not quite understand what this means and what it says about my code. I have this function cria_palavra that returns a pointer, there in main , when I will receive that return in another function insere_fi...
asked by 22.09.2018 / 09:13
1
answer

The queue code has a search error. How can I fix it?

I use the search 2 times in my code and it is a binary search in order to respect the criteria imposed in the heading of this exercise. But the question is the binary search module because the compiler tells me that the arguments are being pa...
asked by 23.09.2018 / 21:07
0
answers

Memory garbage when pointing a pointer

In an attempt to implement an adjacent array graph, I created the createVertice function in which a new "array" would be created and the contents of the graph would be copied to it, adding the new positions. However, when calling this function a...
asked by 24.08.2018 / 20:44
1
answer

Pointers with argc and argv

I have the following code to run on the terminal. It checks if the first argument is a '+' and then adds the next numbers. int main(int argc, char *argv[]) { int i, soma; char oper; oper = *argv[1]; soma = 0; if(oper == '+'){ for(i = 2...
asked by 29.06.2018 / 22:10
1
answer

How to implement a generic MergeSort sorting algorithm?

How to implement a generic MergeSort generic sort algorithm (with function pointer and void pointer) in this function? #include<stdio.h> typedef struct{ inta; intb; }XPTO; void criaVetor(XPTO∗v, int n){ int i; f...
asked by 11.06.2018 / 14:32
0
answers

C - Stack Smashing Detected - How to correctly initialize a graph by adjacency list and insert edges?

I am getting sporadically and without making any changes to the code or entry, an error called Stack Smashing Detected. The only thing I'm doing is initializing a graph and inserting an edge in that, follow the code below: typedef int TipoPeso...
asked by 08.05.2018 / 18:30