Questions tagged as 'ponteiro'

1
answer

What is a shared_ptr?

If possible, with a code example, as this is missing from the reference to really understand when and how to use shared_ptr .     
asked by 16.02.2016 / 17:23
1
answer

Is it interesting to create a type just for a pointer to a type?

I've seen it doing a MinhaEstrutura * be explicitly typed as typedef MinhaEstrutura * pMinhaEstrutura; Why not always do this and get rid of having to rename?     
asked by 12.01.2017 / 11:16
2
answers

How to free memory from an internal malloc to a function that returns a pointer?

How to release an inner% of% to a function that returns a pointer? In a simple way to try to exemplify my doubt, consider the following malloc function: int *f(int tam) { int *ptr = malloc(tam * sizeof *ptr); return ptr; } I...
asked by 22.02.2015 / 21:08
2
answers

Assign a value to the pointer and multiply (directly)

How do I multiply the pointer as soon as I assume a value to it? #include <stdlib.h> #include <stdio.h> int main (void) { int a,*b,*c,*d; printf ("\nInforme um valor: "); scanf ("%i",&a); b = &a; // Co...
asked by 29.06.2016 / 02:23
1
answer

Special treatment for string, why?

I know that arrays are static elements used when you have a pre-determined size that can be used. But speaking of initialization, when the size is already set next to the array, I would like to know, essentially, why you can not use other types...
asked by 21.05.2015 / 15:12
1
answer

Precedence of operators with pointers

Having, for example, the following instructions: int i=10, j=20; int *pti, *ptj; pti = &i; ptj = &j; What is the meaning of j = pti == ptj; and i = pti || ptj; ? In addition, I've read that summing the subtraction b...
asked by 03.08.2015 / 14:46
2
answers

Char pointer or char array?

There is a program I took in a company where pointers of char , type char* , and then allocated a memory for it with malloc , done the operations and in the end deallocated this memory. Usually receives all characters, up to ma...
asked by 03.03.2016 / 14:21
2
answers

Pointers logic

In C ++, you can do the following: int variavel[10][10]; int** variavel; But when I want to create an array 2d, where can I have the first part "unlimited" and the second with limit? tipo ponteiro nova_variavel[limite] And the "reverse"...
asked by 08.02.2014 / 15:55
1
answer

Are variables allocated randomly in memory?

In a book about C, in which I started studying variables, I would say that the variables were randomly placed in memory, for example: int a; int b; printf("a = %d\n", &a); --> 5000 (endereço) (%d ao invés de %p para simplificar) printf...
asked by 02.11.2017 / 22:16
1
answer

What's the difference between these ways of indexing a pointer to array of structs in c?

Is there any difference in the use of these 3 statements? void addCliente(struct cliente *dadosCliente){ dadosCliente[k].nome="oi"; (*(dadosCliente+k)).nome="oi"; (dadosCliente+k)->nome="oi"; } void main(){ struct cliente cl...
asked by 04.02.2014 / 17:27