Questions tagged as 'ponteiro'

2
answers

Why declare pointer to array if arrays are already pointers?

If a char array is already a pointer, why declare a pointer to the array? And what's the difference between char exemplo[10] and char *exemplo[10] ?     
asked by 08.10.2015 / 03:19
3
answers

Use free () without malloc ()?

Could it be a problem to use free() on a pointer that was not allocated with malloc() beyond the unnecessary itself? void funcao (int par) { char *palavra; if(par%2 == 0) { palavra = malloc(3*sizeof(char))...
asked by 29.07.2016 / 16:12
2
answers

Calculate the factorial by reference passage

I am studying pointers I am trying to calculate a factorial of a number, but the result is a totally different value than expected. Here is my code #include<stdio.h> #include<stdlib.h> void calulcafatorial(int num, int *fatorial);...
asked by 03.01.2018 / 11:34
2
answers

Doubt about pointers

This code creates array, initializes and prints, as well as adding, subtracting and multiplying arrays: typedef struct{ int nl; int nc; int **elementos; }MATRIZ; void criar_matriz (int, int, MATRIZ *); void inicializar_...
asked by 11.03.2015 / 23:46
2
answers

Why can not I access the integer vector in the main () function?

I can not access the positions of the integer vector that I loaded in the function loads. In that function I can correctly access the data with: printf("%d\n", n[i]); But in the function main() , below where I call the function loads,...
asked by 07.10.2018 / 15:52
1
answer

How is correct when declaring a variable that is a pointer?

I see that some people do int* variavel; And there are those who do int *variavel; Which one is correct?     
asked by 24.01.2017 / 11:41
1
answer

Pass Array as parameter to function

Make a program in C that reads an x value, dynamically create a vector of x elements and pass that vector to a function that will read the elements of that vector. Then, in the main program, the filled vector must be printed. In addition, before...
asked by 04.05.2016 / 16:36
1
answer

Segmentation fault when accessing pointer contents

I need to declare a vector of pointers, which will point to types float , and do a simple reading of values. The program compiles but after entering 4 values I get a Segmentation fault (core dumped) . Why does this occur because I'v...
asked by 22.12.2015 / 12:55
1
answer

Pointer pointer to change my stack. Why should I use them?

I'm doing a code that consists of parsing an arithmetic expression, and checking if when I open a '(', then I should close a ')'. That is, check whether the expression is valid or not. For this I implemented a stack to help me solve this problem...
asked by 13.07.2017 / 06:02
1
answer

Why is it possible to store a string in a char pointer?

Why does char store a single character and the pointer points to its value in memory, so should it not have only one character? Example: char *str = "Ola"; Why str does not store just one character?     
asked by 17.11.2018 / 17:55