Questions tagged as 'ponteiro'

3
answers

How to make a polymorphic pointer with this pointer in the parameter?

For example, in Qt (correct me, if logic is wrong, I have not done Qt for a long time), you can do this: QLabel label = new QLabel(this); Now let's suppose: #include <iostream> class AbstractBase { public: virtual void A...
asked by 11.02.2014 / 17:22
1
answer

Arithmetic of pointers in C

I'm doubtful of a way to know the length of a vector without using sizeof : int n = *(&arr + 1) - arr; It is known that: arr is of type int ( * ) and (&arr + 1) is of type int ( * )[size] . Wha...
asked by 13.11.2018 / 03:01
1
answer

Data structures - List differences

Please let me know the real difference between these structures below: typedef struct { int info; struct lista * prox struct lista * ant; } tipo_lista; and this: struct noCliente { int tempoUtilizandoMesa; struct noCliente *ant; str...
asked by 01.06.2017 / 15:08
1
answer

The scanf writes string to a pointer that does not have a defined size?

I'm trying to understand how strings work in C. I noticed that even though I can not define any limit for the TextoUm[] (which follows in the code below) in any part of the code, % can write a string to that vector correctly. But the...
asked by 30.11.2016 / 23:24
2
answers

How do I use free () and return the same content?

I wanted to use free() in ls_retorna in the following function, how could I do it in the best way? char* MemCpyX(char *as_origem, int an_inicio, int an_quantidade) { char *ls_retorno = (char*)malloc(an_quantidade); memcp...
asked by 27.07.2016 / 21:35
1
answer

Copying string stored in pointer

What's wrong? #include <stdio.h> #include <string.h> int main(void) { char *str= " teste"; int j = 0; while(str[j] == ' ') j++; memcpy(str, &str[j], strlen(&str[j])+1); printf("%s", str); retur...
asked by 30.04.2016 / 16:49
1
answer

Assigning / Printing values to void * in a structure

#include <stdio.h> typedef struct elem{ void * d; }Elem; main(){ Elem *p; Elem e; double pi = 3.14; e.d = &pi; p->d = &pi; printf("%f\n",p->d); printf("%f\n",e.d); } When I do the...
asked by 28.01.2016 / 20:40
2
answers

Problem with malloc

Galera, to make a small program that given any number, enters a function that divides the number into a vector and returns the number of decimal places (number of positions) that the vector has. In all the guides and tutorials I see says that th...
asked by 06.09.2015 / 23:46
1
answer

Removal item in threaded list C

Well, I'm having a little problem, I'm implementing a simple A *. When I pass the item already checked to the closed list and do the deallocation of the open list item, it is giving undeclared pointer error ... The error is this pointer being...
asked by 25.10.2015 / 04:48
2
answers

Doubt in Struct + C pointer

Given the code below, I wonder why the second printF of the LeAluno procedure does not print correctly? #define MAX 3 typedef struct aluno{ int matricula; float notas[2]; } Aluno ; int t=1; void LeAluno(Aluno *Param){// com ponteiro...
asked by 29.07.2014 / 20:01