Questions tagged [dynamic]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
2answers
1k views

What will realloc() do if the contiguous memory location is already occupied?

Consider- char* name1 = malloc(4 * sizeof(char)); name1 = "Mike"; Now if i want to put "Mike Smith" in the same string "name1", I need 6 more bytes of memory (one for the space and 5 for "Smith". ...
1
vote
1answer
2k views

When we free a dynamically allocated memory, what happens to the pointer pointing at it?

After watching section on "Dynamically allocated memory" (from Week 4) several times, I still have a question unanswered. Consider the following code- // Allocates 4 bytes of memory on heap and ...
1
vote
1answer
50 views

GetString() & Dynamic Memory Allocation

I observed in a walkthrough video in Week 4 (structs-0, I believe) David mentions that any variable created with GetString() should be free()d after its usage, due to the fact that, I vaguely quote ...
1
vote
1answer
236 views

Help understanding edit distance for pset6 similarities

I get the basic gist of edit distance, but there's a part in one of the walkthrough videos for pset6/similarities which I don't understand. https://www.youtube.com/watch?list=PLhQjrBD2T381-...
0
votes
3answers
145 views

Week 4, Section : Dynamic Memory Allocation

After watching Dynamic Memory allocation section and reading this i am a bit confused, if declaring an array int array[10]; and allocating using malloc int* parray = malloc(10 * sizeof(int));...
0
votes
1answer
165 views

Dynamically change the row colour of a table in HTML that was generated using jinja

As part of PSET8 finance additional implementations, I want to dynamically colour the table in history.html. The simple code uses jinja2? to populate and print out a table in html. {% extends "...
0
votes
1answer
146 views

Lecture Week 6: Dynamic programming: rod example, is the recursion approach correct?

so then I was watching the lecture and I thought at the time it would be nice to try implement the example (well, partially at least) used in the lecture. I have two questions: Is my approach to ...
0
votes
1answer
20 views

dynamically allocated memory for a node is changed without any dereferencing?

I am in week 5(data structures) and I tried to make a simple binary search tree. then I tried to create a function for getting around on this tree! this is a part of get_around function : printf(&...