No video

Resize A String Stored In Dynamically Allocated Memory | C Programming Tutorial

  Рет қаралды 1,244

Portfolio Courses

Portfolio Courses

Күн бұрын

How to resize a string stored in dynamically allocated memory using C. Source code: github.com/por.... Check out www.portfolioc... to build a portfolio that will impress employers!

Пікірлер: 6
@PortfolioCourses
@PortfolioCourses 2 ай бұрын
Note: realloc() could fail, this video explains how to handle it: kzfaq.info/get/bejne/qdGhdtGZzaeUio0.html. 🙂 Also note that when using dynamically allocated memory we should use free() after we are done using it, this won't matter in a small teach-a-concept demonstration like this, but in real large program it can cause a memory leak!
@fifaham
@fifaham 2 ай бұрын
Thank you, Kevin.
@dimitrioskalfakis
@dimitrioskalfakis 2 ай бұрын
sure, but if it returns NULL would it not be better to store the return address to a different pointer and then determine if string will point to it? this happens more often than one would think in small embedded chips.
@bugurme1
@bugurme1 2 ай бұрын
in that case you don't want to use realloc? just manually malloc new space and free old space?
@dimitrioskalfakis
@dimitrioskalfakis 2 ай бұрын
@@bugurme1 realloc with a NULL argument amounts to the same thing. i am saying that checking for NULL is important. you can not avoid fragmentation as long as you deal with heap instead of stack.
@PortfolioCourses
@PortfolioCourses 2 ай бұрын
Yeah this video is intended for beginners, if anyone wants to learn more about handling realloc failures check out this video covering the topic: kzfaq.info/get/bejne/qdGhdtGZzaeUio0.html
How To Resize An Array | C Programming Tutorial
11:16
Portfolio Courses
Рет қаралды 1,8 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 252 М.
Get 10 Mega Boxes OR 60 Starr Drops!!
01:39
Brawl Stars
Рет қаралды 19 МЛН
Люблю детей 💕💕💕🥰 #aminkavitaminka #aminokka #miminka #дети
00:24
Аминка Витаминка
Рет қаралды 499 М.
Parenting hacks and gadgets against mosquitoes 🦟👶
00:21
Let's GLOW!
Рет қаралды 13 МЛН
C++ strchr
0:29
Jakubication
Рет қаралды 149
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58
Introduction To Threads (pthreads) | C Programming Tutorial
13:39
Portfolio Courses
Рет қаралды 91 М.
you will never ask about pointers again after watching this video
8:03
Low Level Learning
Рет қаралды 2,1 МЛН
Segmentation Faults And Common Causes | C Programming Tutorial
10:51
Portfolio Courses
Рет қаралды 3,1 М.
10 Math Concepts for Programmers
9:32
Fireship
Рет қаралды 1,8 МЛН
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 301 М.
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
ARRAYLIST VS LINKEDLIST
21:20
Core Dumped
Рет қаралды 59 М.
Understanding and implementing a Hash Table (in C)
24:54
Jacob Sorber
Рет қаралды 351 М.