Posts by Pierre Campos • 129 points
5 posts
-
4
votes2
answers70
viewsQ: Pointer pointing to another pointer, how to use the free() correctly?
When I have a pointer pointing to another pointer like: int *ponteiro1 = malloc(sizeof(int)); int *ponteiro2; *ponteiro1 = 5; ponteiro2 = ponteiro1; free(ponteiro2); And I use the command…
-
2
votes1
answer122
viewsQ: How to copy a structure pointer?
Is it possible to clone a structure pointer? Follow the code: typedef struct{ int numero; }estrutura; int main(int argc, char *argv[]){ estrutura *i = (estrutura *)malloc(sizeof(estrutura));…
-
2
votes1
answer59
viewsQ: Parentheses in a pointer to pointer
I’m studying a binary tree structure and I got in doubt in a part of the code. #include <stdio.h> #include <stdlib.h> typedef struct tree { int num; struct tree* sad; struct tree* sae; }…
-
1
votes1
answer86
viewsQ: Problem for centralized printing in C
I have the following problem, in my code I want the program to centrally print the number 1 after the "word", and to center I am using the parameter "%-20s \t" to try to center the number after the…
-
1
votes1
answer1445
viewsQ: Compile project with multiple files . c in Vscode - C language
Good afternoon, I’m having trouble separating my code into . c and . h in Vscode. Follows the implementation: main. c #include "head.h" int main(){ printar(5); } head. h #include<stdio.h>…