Questions tagged as 'ponteiro'

1
answer

Using pointer can make my code faster?

I was told that if I work using pointers the program will be faster. If instead of using index to traverse a vector I use the pointer, does it get better?     
asked by 30.07.2018 / 20:40
1
answer

How to reference mat [x] [y] in pointer notation

I'm working with programming in c , specifically with pointers and dynamic allocation, I need to respond to an exercise that asks for the following:    How to reference mat [x] [y] in pointer notation.     
asked by 16.10.2017 / 02:43
1
answer

Why use a pointer in this algorithm?

When I retreat the code does not work. Why? And why is the insert emulation algorithm algorithm only suitable for list of small entries, type array and list / p> void insert_sort(int *vetor, int TAM){ int i, j, aux; for(i = 1...
asked by 15.11.2017 / 18:49
1
answer

Open a file using secondary function

I need to create a function that "points" a file pointer to a particular file in the computer's memory. I was able to do this: #include <stdio.h> void abre(FILE*); void procedimento(); int main () { procedimento(); return 0; }...
asked by 02.09.2015 / 15:49
1
answer

Why can I only handle files with pointer?

In the statement I always have to put FILE *Arq; If I put it without * it gives an error. What is the reason?     
asked by 20.09.2018 / 21:24
2
answers

Problems with function returning character vector in C ++

Follow the code: #include <iostream> char* criaVetor(){ char vetor[20]="Olá mundo!"; return vetor; } int main(){ char retorno[20]=criaVetor; std::cout << retorno; return 0; }    error: array must be i...
asked by 14.08.2017 / 16:54
1
answer

What is the difference between pointer to vector and pointer to variable?

int A; int* pA = 1; int Vect[2] = {1,2}; int* pVect; pA = &A; *pA = 2; pVect = Vect; pVect[0] = 10; In the case I have a pointer to a variable and then to a vector, and I want to change its values by the pointer. Why is there such a dive...
asked by 29.03.2017 / 06:31
1
answer

Is it correct to clean an internal malloc to a function with it?

Well given the following code is easy to do memory management: Sample Code (in C): #include <stdio.h> #include <stdlib.h> int *criarValor(void){ int *valor = malloc(sizeof *valor); *valor = 10; return valor; }...
asked by 30.05.2015 / 17:45
1
answer

Size of struct allocation

When I declare a normal variable of type int for example, the compiler goes there and, depending on the architecture, separates 4 bytes . struct exemplo{ int x; int b; }; int main(){ struct exemplo exemplo; } When I declare...
asked by 12.04.2015 / 04:36
1
answer

Allocation of objects and pointers

How do I allocate a pointer, which points to a class, and that of an object? Is there a difference? Size, etc.     
asked by 05.04.2015 / 01:44