Posts by Gustavo Dambros • 50 points
11 posts
-
1
votes1
answer56
viewsA: Passing by reference, and saving data from a file in a vector
You need to remember that the array line is local and the function Strtok returns a pointer to some position of that array, so you can’t just copy that address to your structure, because the data in…
-
0
votes1
answer59
viewsA: Search between two vectors
This problem is very similar to the "Longest prefix match", famous because of the Ipv4 and Ipv6 routing protocols. The brute force algorithm for this problem would be as follows:…
canswered Gustavo Dambros 50 -
0
votes1
answer462
viewsA: Problem in ordered insertion code of structs (records) in files
The problem is that you will never fall into the second condition (you already treat the case of returning zero in the first). if (strcmp(auxiliar.nome, menor.nome) <= 0) {...} else if…
-
0
votes1
answer1708
viewsA: Problem with swapping vector positions
The error is in the loop where you exchange the values. You are exchanging the 1° value with the 20°, the 2° with the 19° and so on. The code below does what is requested. //troca dos valores…
-
0
votes1
answer43
viewsA: Breakpoint in Looktree paid function (Binary trees)
Your code has some problems in logic, for example, the function Destrurnodo calls the Procuraarvoreapaga. You are also not erasing the reference of the deleted node in the parent node, causing it to…
-
0
votes1
answer61
viewsA: List
I don’t know if the program does what it should do, but if you replace the Dlist* Dlist variable name with any other than Dlist, the program works. In other words, never use the esrutura name as a…
-
0
votes1
answer106
viewsA: Function problem for printing names - Chained list (C language)
The problem is that you are statically allocating the p1_main variable, so every time you call: criar_registro(&p1_main); insere_ini(&p2_main, &p1_main); is the same record that you are…
canswered Gustavo Dambros 50 -
0
votes1
answer629
viewsA: How to pass information from a file to a dynamic vector of C structures?
I prefer to use fgets instead of scanf to read lines from a file (https://stackoverflow.com/questions/8917550/difference-between-fgets-and-fscanf). while (fgets(v->nome, 49, f)){…
-
0
votes1
answer35
viewsA: Tree b is partitioning the wrong node
Your binary search function is incorrect. if (start == end) is never satisfied because of the while condition. I changed other conditions so that it always returns the position where the value…
-
0
votes1
answer383
viewsA: Calculate diagonals of an array using Threads
I made the code down using windows API, it shouldn’t be too hard to move to pthreads. Another (perhaps more efficient) solution would be to use Thread Pool. #include <stdio.h> #include…
canswered Gustavo Dambros 50 -
2
votes1
answer213
viewsA: What is the architecture of Cleopatra?
Some universities create some architectures to support the teaching of computer architecture chairs. These are usually based on the major architectures of the market. Cleopatra architecture is one…