alocação

strcpy () in struct string

I have a struct Time that has a Vector char name[30], the problem starts when I try to copy a value to this string with the ... "Palmeiras"); time *t = c.first; printf("%s", t->name); return 0; The value of print for t->name is always garbage.

Allocate space for a double vector vector vector

I am trying to allocate space in memory for a double vector vector vector. I know that for a vector vector I can do vector& ... se of vector of vector of Vector this definition is not so clear. Is there any possibility of allocation for this other case?

Are variables declared within blocks or subprograms dynamically allocated?

I am reading the book "Algorithms and programming with examples in Pascal and C" and in it there are two paragraphs that left ... allocation. This correct this statement? In my understanding, only allocation via pointers is considered dynamic allocation.

What is the difference in the syntaxes ptr = (int*) malloc(sizeof (int)) and ptr = malloc(sizeof (int))?

I have a doubt about dynamic allocation in C. At the time of allocating memory I have seen these two types of syntax: ptr ... t the difference in use between them. Each site seems to talk about something different. Could anyone explain the difference?

What is the difference between" calloc () "and"malloc ()"?

What does the function calloc() do that malloc() does not? Why is it almost not used?

Is Typecast from malloc recommended?

I have already read about it that it is not recommended to do the typecast of the malloc when we are allocating memory to a n ... = malloc(sizeof(int)); *v = 10; *x = 5; *z = 50; printf("v=%i\nx=%i\nz=%i", *v, *x, *z); return 0; }

Dynamic allocation with struct

/* [Error] expected primary-expression before'*' token [Error] 'dia' was not declared in this scope [Error] 'mes' wa ... 10; ptr->ano=1990; printf("%i",dia); printf("%i", mes); printf("%i",ano); system("pause>null"); return 0; }

Problem with dynamic allocation of bidimentional arrays in C

I need to make a product of arrays in which the user must enter the dimensions and terms of the arrays, but the program simpl ... ++i) { for (j = 0; j < colunasB; ++j) { printf("%f ", C[i][j]); } printf("\n\n"); } return 0;}

Structure and pointers in C: Binary Tree

Hello, I'm trying to create a tree of mathematical expressions with the following logic: My expression is a string, and I h ... break; } } } return 0; } If you have another way to solve this problem, let me know!

Trying to understand pointers in c / c++

Hi guys I'm new to stack and it's as follows: I am studying pointers and did the following code: typedef struct { char ... able in a "simple"way. I know I'm using pointer but would like the justification of why a case it works and another does not.

How to allocate in contiguous memory a structure containing 1 vector with user-defined size?

I was thinking about how to answer this question and I came to the conclusion that I would need a data structure with: th ... tead of a vector with the pointers), how would I rescue the n-th element of type struct conjunto from this region of memory?

Dynamic allocation for struct

I need to dynamically allocate space for a structure, but I am not able and do not know of my error is at the time of declara ... "\t Estado: "); ler_string(info[posicao].estado, 2); printf("\t CEP: "); scanf("%lu", &info[posicao].cep); }

Dynamic stack - C

I am studying dynamic stack from the code below: #include <stdio.h> #include <stdlib.h> #define tam 50 // --- ... o assemble the structure, but I am in doubt in some parts that are commented in the code, in case what the specific lines do

Lap allocate a memory based on the size of what the user typed

How can I make it right after the user enters a String the program counts the 'x' number of characters from this and allocate ... later, so before the string is 'picked up' there would be no bytes allocated to store it. Does anyone know how I solve this?

When to allocate memory dynamically?

In C++ you can easily declare an object or variable like this: tipo_da_variável nome_da_variável; This type of statement is ... r type, ie start, we do not know how much memory the program will use and even then, it was not necessary to use new + delete

Dynamic allocation in C-unknowingly allocating the total amount of elements

I am having a doubt regarding dynamic allocation in c, as to the use of function malloc(). If we take, for example, a case o ... t had only 10 characters? Would I occupy only the first 10 spaces and the other 10? Would there be a waste in that case then?

Dynamic vector allocation

Follows the statement: Make a program that reads keyboard numbers and stores them in a dynamically allocated vector. T ... = 0); printf("\n\n") ; for (int i=0; i<c2; i++) printf("%d ", vet[i]); system("pause"); return 0; }

Is there realloc () in C++?

Is realloc() unique to C? Would there be any function that would be the same in C++?

dynamic array allocation within a struct

Statement and Code: Knife a program that stores films produced by several directors and: - Create and read a vec ... the array correctly? Because it doesn't work when I try to put more than 2 movies in the same director! since ja, thank you

Exited error, segmentation fault in C

I am trying to make a function that returns me a date according to an integer and always the error appears: Exited, segment ... ; datas[i].ano % 10 <= k){ teste[i] = datas[i]; } } return *teste; }