Posts by Patrick Cardoso • 131 points
6 posts
-
0
votes1
answer101
viewsQ: Bizarre error with dynamic allocation
I wrote this simple program: #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char *nome; nome = (char *)malloc(10 * sizeof(char)); if(nome == NULL) {…
-
1
votes1
answer125
viewsQ: What is the difference between char (*ptr)[20] and char *ptr[20]?
I’m studying pointers and came across these statements, but I couldn’t understand it very well. Could you help me? Thank you.
-
1
votes1
answer760
viewsQ: Arrays and Pointers
Hello, how do I point to a multidimensional matrix? I know that to do this with a vector (one-dimensional matrix), it’s like this: int v[5]; int *ptr = v; I understand that very well, but with a…
-
6
votes1
answer132
viewsQ: Are variables randomly allocated in memory?
In a book about C, in which I started studying variables, it said that variables were randomly put into memory, for example: int a; int b; printf("a = %d\n", &a); --> 5000 (endereço) (%d ao…
-
3
votes2
answers797
viewsQ: Why can you pass a char vector to the scanf as the direct address or variable?
If the name of the vector or matrix is already the address of the first element, why scanf(), using the primitive types (int, char, float, double) I need to pass the address, being that when we want…
-
0
votes2
answers81
viewsQ: (Error of Segmentation fault)
People don’t know where the bug is. Every time I compile it accuses error of Segmentation fault (core dumped), can anyone help me? The code is here: #include <stdio.h> int strlen(char *s);…