Read All File Lines Into A Dynamically Allocated Array Of Strings | C Programming Example

  Рет қаралды 13,317

Portfolio Courses

Portfolio Courses

Күн бұрын

Пікірлер: 47
@Majkieboy
@Majkieboy 2 жыл бұрын
Very happy to have found these, not enough C content around these days. Good job.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you, I'm glad you found the channel too! :-)
@MrBolcetik
@MrBolcetik 2 жыл бұрын
I am currently an active student in Software Engineering, and every time you post a video it always related with the content that I am currently dealing with 😂. Thank you for this great video!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're very welcome! :-) And I'm really glad to hear these videos are relevant to what you are learning as a student... helping students is the biggest reason why I like making these videos.
@MrBolcetik
@MrBolcetik 2 жыл бұрын
@@PortfolioCourses I was coding a function called get_next_line and this is just what i was needed 😊
@fifaham
@fifaham Жыл бұрын
Very helpful and useful, thank you Kevin. The good things about microcontrollers is that they can have their built-in memory expanded by connecting them to external memory, and that can be very large. A multiple blocks of memory chips can store large files of data and text for processing them at later time.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome Firas! :-) And thank you for sharing this information with everyone too.
@edenng8431
@edenng8431 2 жыл бұрын
Fantastic! Great details! Thank you for updating the C series.👍
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome Eden, I'm glad you enjoyed it! :-)
@idanmariani8601
@idanmariani8601 2 жыл бұрын
thank you very much like allways.. i wish everyone will get to know your awsome channel and have tons of subscribed your the best teacher ever.. :)
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you very much for the support Idan! :-)
@arthur_p_dent4282
@arthur_p_dent4282 2 жыл бұрын
Your content is second to non. Thanks you so much.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You’re very welcome Arthur, and thank you for this kind feedback! :-)
@dev_ression
@dev_ression 2 жыл бұрын
great explanation bro!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you for the positive feedback, I’m glad you enjoyed the explanation! :-)
@dev_ression
@dev_ression 2 жыл бұрын
@@PortfolioCourses no problem!
@naboulsikhalid7763
@naboulsikhalid7763 11 ай бұрын
Great content, I think everything is mentioned here. Thank you KEVIN
@dogdog5994
@dogdog5994 2 жыл бұрын
A little suggestion. You made a video about threading in C using the POSIX pthread library. I suggest videos about C11 threads and maybe more videos about POSIX threads (pthread).
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
It’s funny you’re reading my mind haha, I’ve thought of doing more posix thread topics related to things like mutexes, passing arguments to functions, etc. And C11 threads is a topic I want to cover for sure too! :-)
@dogdog5994
@dogdog5994 2 жыл бұрын
POSIX pthread vs. C11 threads and the differences would be an interesting topic too. Various compilers have supported pthread for quite a long time but it's not a part of the official C Standards. There was no official threads in the C Standard until C11 as far as I know.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
My understanding is that "underneath" C11 threads are implemented as pthreads in most platforms that support pthreads, and that pthreads are more widely used due to supporting more features even though C11 threads are more portable.
@pragunmike1642
@pragunmike1642 Жыл бұрын
This is fab. Thank you 🙌🏻🙌🏻🙌🏻
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You’re welcome, I’m glad you enjoyed it! :-)
@LMZ914
@LMZ914 7 ай бұрын
Thank you sir you are the best
@richarddaygm
@richarddaygm 8 ай бұрын
It is obvious but worth pointing out sizeof(char) is always 1, unlike sizeof(char *) which is the size of the pointer. So in the realloc, there is no point in timesing by sizeof(char), even though it would be more symmetrically pleasing!
@bettyswunghole3310
@bettyswunghole3310 5 ай бұрын
"Stack Overflow" strongly recommends *_against_* using statements like "if (feof(file))" for reasons I didn't fully understand...
@ziwaang2250
@ziwaang2250 Жыл бұрын
Great video! For a 2D string array, would it then be "char ***" ?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Yes, that should work, and what you would have would be a 2D array of pointers to strings essentially. :-)
@ziwaang2250
@ziwaang2250 Жыл бұрын
@@PortfolioCourses Thank You!
@sgarcia1070
@sgarcia1070 Жыл бұрын
I have two quick questions, what is the purpose of using the value of 1024 as suppose to another value, and my second question is does free() erase what’s in the string?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
There is no particular reason. It's a big round number that's divisible by 2 (divisibility by 2 can 'play well' with computers in general, compared to something like 537 or something). Another strategy we could use that may be better in some circumstances is to double the amount of memory allocated for the block each time. I've taken an assumption that this would be overkill and that more conservatively increasing the size by 1024 will be OK. And no, free() does not erase what's free'd. Those are both great questions by the way! :-)
@yamithere_
@yamithere_ Жыл бұрын
I just wanna ask what is the difference between having brackets after the for loop and nesting the next for loop compared to the ones without the brackets?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
When we use brackets, we an have multiple statements in the "body" of the for loop. Without brackets, we can only have a single statement. :-)
@yamithere_
@yamithere_ Жыл бұрын
@@PortfolioCourses Thank you!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome! :-)
@Mo3au4HbIu_Ba3oH
@Mo3au4HbIu_Ba3oH Жыл бұрын
I was looking for some copper, but found the real gold
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I’m glad you enjoyed it! :-)
@ramakrishna4092
@ramakrishna4092 2 жыл бұрын
Wonderful explanation sir and congratulations for 22k sub...👏👏👏 I have doubt here .. typedef int (*function)(int a, int b); this is one way I know typedef the function pointer but I'm getting confused how this is acting as function pointer Below syntax can you pls explain this . "typedef int function(int a, int b);" I have also found this code sample using the above syntax #include int add(int a, int b) { return a + b; } int sub(int a, int b) { return a - b; } typedef int function(int a, int b); int call_function(function *p, int a, int b) { return p(a, b); } int main(void) { int sum; sum = call_function(&add, 10, 5); printf("add: %d ", sum); sum = call_function(&sub, 10, 5); printf("sub: %d ", sum); return 0; }
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Hi Rama, it looks like this line here: typedef int function(int a, int b); is creating "function" as a typedef, effectively a synonym, for a function that returns an int and accepts two ints as arguments. And then here: int call_function(function *p, int a, int b) { call_function accepts a pointer to a function like this as an argument, which is supplied when it is passed the address of add and sum. :-)
@jerryli5555
@jerryli5555 Жыл бұрын
The getline() Function can read a whole line
@IanHouchin
@IanHouchin Жыл бұрын
So does fgets. But getline() is a bit more complicated than fgets.
@studentofedison421
@studentofedison421 10 ай бұрын
why **line instead of *line . why line is a pointer to pointer to char instead of pointer to char
@yoruichi5802
@yoruichi5802 2 жыл бұрын
I tought it was forbiden to exit a loop with a break
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
No, it’s not forbidden, it’s part of why it’s in the language. :-) Maybe a teacher would advise a student not to use break so students learn to use loops “the normal way”. But using breaks in a loop is normal in practice.
@yoruichi5802
@yoruichi5802 2 жыл бұрын
@@PortfolioCourses true!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
@@yoruichi5802 🙂
@YoungOrbital
@YoungOrbital 11 ай бұрын
while( !feof(file) )
Dynamic Arrays in C
11:46
Dylan Falconer
Рет қаралды 74 М.
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
Read And Write An Array Of Structs To A Binary File | C Programming Example
18:27
C++ Dynamic Arrays (Dynamically Allocated Array)
8:59
Kenny Yip Coding
Рет қаралды 8 М.
why do header files even exist?
10:53
Low Level
Рет қаралды 454 М.
Read CSV File Data Into An Array Of Structs | C Programming Example
11:05
Portfolio Courses
Рет қаралды 45 М.
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58
Dynamically Allocate An Array Of Structs | C Programming Tutorial
15:11
Portfolio Courses
Рет қаралды 38 М.
arrays are weird
6:57
Low Level
Рет қаралды 117 М.
Reading/Writing structs to files (aka Serialization)
14:41
CodeVault
Рет қаралды 77 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 199 М.
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН