Strings in C

  Рет қаралды 54,812

Jacob Sorber

Jacob Sorber

5 жыл бұрын

Patreon ➤ / jacobsorber
Courses ➤ jacobsorber.thinkific.com
Website ➤ www.jacobsorber.com
---
My other videos for C beginners:
• Beginner C Videos
***
Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.
About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.
More about me and what I do:
www.jacobsorber.com
people.cs.clemson.edu/~jsorber/
persist.cs.clemson.edu/
To Support the Channel:
+ like, subscribe, spread the word
+ contribute via Patreon --- [ / jacobsorber ]
+ rep the channel with nerdy merch --- [teespring.com/stores/jacob-so...]
Source code is also available to Patreon supporters. --- [jsorber-youtube-source.heroku...]
Want me to review your code?
Email the code to js.reviews.code@gmail.com. Code should be simple and in one of the following languages: C, C++, python, java, ruby. You must be the author of the code and have rights to post it. Please include the following statement in your email: "I attest that this is my code, and I hereby give Jacob Sorber the right to use, review, post, comment on, and modify this code on his videos."
You can also find more info about code reviews here.
• I want to review your ...

Пікірлер: 82
@tahaalkhashmany5678
@tahaalkhashmany5678 4 жыл бұрын
'In C strings are really simple'. They gave me hell when I first learned C :D
@thingsiplay
@thingsiplay 3 жыл бұрын
The first programming book I ever read was in somewhat early 2000s the original "The Programming Language C" by Kernighan and Ritchie. Well I don't program in C still, but this basic low level stuff helped me understanding how computers work in general. Now I am in Rust and Strings are very complicated again, because of all the error handling and Unicode. In fact it is not different from C somewhat, but it enforces you to do all the stuff. Which is a good thing to me. If you did the same stuff in C, it would be as much complicated. So, C strings are simple, but the work and implication that it comes with is not.
@seek2imagine423
@seek2imagine423 Жыл бұрын
I am so struggling with that in C. It's like hard to wrap your head around strings, arrays, and pointers.
@wlcrutch
@wlcrutch Жыл бұрын
I am there right now…lol
@sarthak761
@sarthak761 2 жыл бұрын
I am an Embedded Firmware Developer from Electronics background and yes we code in Embedded C, our job is to play around with the stuff people are scared of ....that is pointers and structures and arrays all together. No DS algo computer science stuff. Your channel is the best and I constantly watch your videos for revision.
@VinayagaMotorsTsy
@VinayagaMotorsTsy Жыл бұрын
Me too bro... BIOS DEPARTMENT
@superfaqer
@superfaqer 4 жыл бұрын
m8 you deserve more views. Its precise and concise, which is perfect for someone who can already program, and is looking for syntax and stuff for a new language. Also very nicely shot and edited :)
@damiancampbell1743
@damiancampbell1743 3 жыл бұрын
8:07 Python Programmer: *Laughs in x[::-1]*
@pattyspanker8955
@pattyspanker8955 11 ай бұрын
It's too powerful
@TheJackpotgamer
@TheJackpotgamer 4 жыл бұрын
I'm using these video's to gain a deeper understanding of common c programming concepts, and these are brilliant! thanks for all the hard work
@JacobSorber
@JacobSorber 4 жыл бұрын
Thanks. I'm glad they're helping.
@pedrocardoso4329
@pedrocardoso4329 5 жыл бұрын
Great Video again, it’s a crime you having so few views in your channel i’m already sharing with my friends your videos. Keep going!
@JacobSorber
@JacobSorber 5 жыл бұрын
I know! It's tragic. Thanks for spreading the word, Pedro.
@RoddyRebel
@RoddyRebel 4 жыл бұрын
Thank you, Jacob, You are the BEST!
@Liam-ey2gs
@Liam-ey2gs 2 жыл бұрын
Thank you for this series of videos
@IndellableHatesHandles
@IndellableHatesHandles Жыл бұрын
Technically the string is the *size* of a pointer, which is usually either 4 or 8 bytes. The amount you have to allocate is the *length* of the string + 1, multiplied by the size of a char.
@santoshsco
@santoshsco 3 жыл бұрын
Best channel for interview preparations :)
@marcocicognani2k
@marcocicognani2k 5 жыл бұрын
Hi, I really love your videos, keep going. Best regards
@motasemahmed7736
@motasemahmed7736 5 жыл бұрын
Thanks!! 😀
@08Carl
@08Carl Жыл бұрын
Thanks
@adeled8833
@adeled8833 4 жыл бұрын
Thank you , these materials are a life saver for an Ecole 42 student. I have to make these functions from scratch 🤧
@JacobSorber
@JacobSorber 4 жыл бұрын
You're welcome. Glad they were helpful.
@yizongzhou5893
@yizongzhou5893 4 жыл бұрын
hi, I am going to the next piscine. Can I ask you a few questions ?
@adeled8833
@adeled8833 4 жыл бұрын
Yizong ZHOU go ahead :)
@rorak6142
@rorak6142 Жыл бұрын
2:53 it's 8 bytes because it's a pointer to the start of the string :D
@favouronwuchekwa
@favouronwuchekwa Жыл бұрын
Ohh my gosh I am so glad I found this channel
@JacobSorber
@JacobSorber Жыл бұрын
Me too. Thanks for being here.
@DJJOHN92
@DJJOHN92 5 жыл бұрын
+1 on the future Unicode video. Maybe include explanation of how Go deals with text for instance (runes, bytes, slices). Thanks for your great content!
@JacobSorber
@JacobSorber 5 жыл бұрын
I'll see what I can do. I don't have a lot of experience with Go, but I'll put it on the idea list. Could be a good excuse to learn something new.
@TusharKumarParthsarathi
@TusharKumarParthsarathi Жыл бұрын
How to style my macbook terminal like you? Please tell which theme or settings you are using.
@aotearoajd
@aotearoajd 5 жыл бұрын
What IDE are you using? Also, I have been using emacs but find it kinda hard going - is it worth persevering with it since I know it (or VIM) are in common use among professionals?
@JacobSorber
@JacobSorber 5 жыл бұрын
VI/VIM/emacs are useful because they can be used quickly from a terminal connection and little bandwidth. But, I wouldn't say that they're the most used editors by professionals. They are useful at times. I tend to use vs code or atom these days unless I have a good reason to use something else (like a low bandwidth ssh connection).
@ttc0419
@ttc0419 5 жыл бұрын
Greate video, could you made another video about what is stack trace and how to read stack traces via gdb?
@JacobSorber
@JacobSorber 5 жыл бұрын
Thanks. Yeah, that's on my list of videos to make. Coming soon...or whenever I can find the time. :)
@Mishiman
@Mishiman 5 жыл бұрын
Hey, you've got the best videos about C out there man. I've been wondering if you'd be able to do a video about writing to stdout and reading from stdin? And I don't mean going over library functions like printf and the like, I mean going in depth to explain how it works. I know it's very platform-dependent, but maybe there's some general idea behind it? I've been reading the libc library in order to understand how putchar() exactly works, but no luck. There's so little info on the internet too Great channel
@Mishiman
@Mishiman 5 жыл бұрын
Yes, I know there are system calls like write(), but that's also written by someone and is not part of the C language (I think), and it ddoesn't answer any of my questions
@JacobSorber
@JacobSorber 5 жыл бұрын
Hi Victor. Thanks. I'm not 100% sure what you're looking for. Are you trying to understand how pipes are implemented in the kernel? I see you already know about the write system call. Yes, someone wrote it. It will be different for every operating system out there. Or are you just interested in how the pipe abstraction works?
@Mishiman
@Mishiman 5 жыл бұрын
@@JacobSorber To put it in simpler words - I'm trying to understand what exactly happens when you use, let's say, putchar(). I know the function writes to stdout, which is picked up on the console (or some other interface), but that's too vague for me :) My research taught me that there might be some addresses in memory tied to video RAM, which you can write to. I'm curious about reading from stdin, too. I'm not sure if it's related to pipelines, I saw your video about pipes (which was mega interesting). Not sure if pipes and pipelines are the same, I'm a web developer learning C as part of my uni curriculum, and this stuff really fascinates me
@JacobSorber
@JacobSorber 5 жыл бұрын
@@Mishiman putchar calls the write system call, which hands the character to the kernel and tells the kernel to put it to stdout. The kernel knows that stdout (a pipe) is connected to something - could be a file, could be your terminal, could be the stdin for another process (the terminal is just a process). If it's a file, then the kernel will just write the character to a file. If it's a process, the character will stay in its stdin, until it reads it in (basically until the process asks the kernel for it). Then the process decides what to do with it. In the terminal's case, it asks the kernel to draw the text on the screen. If the window is visible, the kernel will draw the text to the screen, which involves video memory and device drivers and gets complicated, depending on how deep into the specifics you want to go. It's also fairly OS-specific. They can all implement pipes and drawing to the screen however they like. I'll add it to my video idea list and see what I can put together in the future, but hopefully, this helps for now.
@Mishiman
@Mishiman 5 жыл бұрын
@@JacobSorber This is very informative, thank you!
@JustinZaf
@JustinZaf 5 жыл бұрын
Loved the video hey Jacob sir thank you so much for replying me last time I had one request for you please I can't get my head around Sequence points in C what does it mean ? Please Make a video on it Whole Internet is full of definitions tht are not as lucid as I want! Thank you
@JacobSorber
@JacobSorber 4 жыл бұрын
Not sure how I missed this 10 months ago. Sorry. But, yeah, I'll see what I can do. Sequence points can be a little confusing.
@ajalanbrown2200
@ajalanbrown2200 10 ай бұрын
you use omf for your terminal, subscribed.
@prashantgaur5123
@prashantgaur5123 5 жыл бұрын
Hi Jacob, I have been following you from long and knowing the fact that you love system programming. I have a request ...... Can we hear something on ABI (binary interface) and the way they got invoked whenever we call an API desiring for a system call..
@JacobSorber
@JacobSorber 5 жыл бұрын
Yeah, that's probably doable. I'll see what I can do.
@user-mx6gi8fy6j
@user-mx6gi8fy6j 2 жыл бұрын
dude WHAT THE FUCK ARE THOSE HEARTBEATS IN BG
@Sahilbc-wj8qk
@Sahilbc-wj8qk 5 жыл бұрын
Please make video on signals from start.
@JacobSorber
@JacobSorber 5 жыл бұрын
So, I have one video on signals already (kzfaq.info/get/bejne/bpl9aJB_tarJh6c.html). Let me know if there are things that I didn't discuss in that one that you would like to hear about.
@shailendrasingh007
@shailendrasingh007 4 жыл бұрын
i cant use "man" on cmd for getting help about any function in c... how to do that in windows? to get the syntax of any function?
@JacobSorber
@JacobSorber 4 жыл бұрын
You can install cygwin, or something else that makes windows look more like Unix/Linux (or check out WSL). Then you will have man pages. There's also the MSDN online documentation.
@shailendrasingh007
@shailendrasingh007 4 жыл бұрын
@@JacobSorber thanks! When i start your videos i feel like what the hell is going on. So i have to pause and re-watch. But i like it this way! I'm a fan! I have a new concept product in my mind, and i have quit my job to work upon it. I have no idea how embedded systems are programmed on commercial scale, they definitely don't connect each board to computer via USB and use Arduino ide to install the program. I hope as soon as I complete your basics of c , and embedded systems programing playlist, I'd be able to do the same. I hope what i have in mind works and i could come and thank you in person!
@strawberry_cake1703
@strawberry_cake1703 5 ай бұрын
@ 2:34 shouldn't we use *str1 here, and shouldn't str1 be a pointer?, I tried using both the str1 and *str1 in the printf statement and got the same ans either way but I don't understand why that would be the case
@chikatikah3838
@chikatikah3838 4 жыл бұрын
Doesn’t a null-character mark the end of strings and not a zero?
@JacobSorber
@JacobSorber 4 жыл бұрын
A null character is a zero.
@iainbarkley3491
@iainbarkley3491 Жыл бұрын
I'm sorry for being pedantic, but at 1:14, you mentioned 'some value from 0 to 128', it should be from 0 to 127. Your videos are still excellent however, and you have one of the best channels for people getting into embedded development.
@JacobSorber
@JacobSorber 11 ай бұрын
Good point. Thanks.
@haltarys
@haltarys 5 жыл бұрын
Technically ASCII is from 0 to 127 but great video anyway
@JacobSorber
@JacobSorber 5 жыл бұрын
Very true. Thanks, and I'm so sorry.
@Hersonrock12
@Hersonrock12 4 жыл бұрын
Question... he said "Hello World!" would be 13 bytes counting the null byte, yet strlen() gave 12 bytes as output. Perhaps strlen() does not really could the null byte either? but in reality there are 13 bytes?
@JacobSorber
@JacobSorber 4 жыл бұрын
strlen doesn't count the null, but there are 13 bytes.
@Hersonrock12
@Hersonrock12 4 жыл бұрын
@@JacobSorber good stuff. Thanks!
@AlexJacksonSmith
@AlexJacksonSmith 2 жыл бұрын
You are very good and I appreciate what you have done here. I just miss the Lego from the earlier videos... :) A.,
@jimparsons6803
@jimparsons6803 2 жыл бұрын
I've programmed in FORTRAN, BASIC, and C, and C++ and a little in Python. Each has its charms, but C and C++ are more "charming?"
@shekharmaela2308
@shekharmaela2308 5 жыл бұрын
Sounds a lot like you read my message and wanted to make vids based off the email I sent about StringIO...
@JacobSorber
@JacobSorber 5 жыл бұрын
Maybe I did. :)
@shekharmaela2308
@shekharmaela2308 5 жыл бұрын
@@JacobSorber Make sure to update your clone, I just added a few new features and also did a bit of cleanup to StringIO. All that's really left to flesh out IIRC is number conversion, Deformatting is like half done too.
@beduin024
@beduin024 2 жыл бұрын
*0 to 127
@lorensims4846
@lorensims4846 3 жыл бұрын
Say, you know why programmers can’t tell the difference between Halloween and Christmas? OCT 31 = DEC 25
@adolfocarrillo248
@adolfocarrillo248 Жыл бұрын
Holy moly, this is a good one🤣, thanks for sharing it. I wish you have a great 2023 year.
@adolfocarrillo248
@adolfocarrillo248 Жыл бұрын
By the way, do you know why astronauts uses Linux up there in the 🚀 space?? 🤭...because they can't open windows🤣
@drw0if
@drw0if 5 жыл бұрын
Please don't use strcpy while manipulating strings in C, this will lead in possible buffer overflow and pwn your software. Use strncpy instead! Great video, though
@JacobSorber
@JacobSorber 5 жыл бұрын
Thanks. And, very true. I was thinking about doing a follow on video about that. For this video, I just want to go through the basics of how strings work.
@BobChess
@BobChess 23 күн бұрын
"String is very easy" Tell me the length of strings
@martiananomaly
@martiananomaly 2 жыл бұрын
lmao why do you look like Matthew McConaughey
@pawan1855
@pawan1855 3 жыл бұрын
This guy looks like "Matthew McConaughey"....🤔
@amalldekan1432
@amalldekan1432 3 жыл бұрын
yea...
@NavidRigiEbrahimi
@NavidRigiEbrahimi Жыл бұрын
great, but you talk fast, and we can't fully see the code.
@me2831
@me2831 2 жыл бұрын
U are great, but u code so fast! I had to pause so many times!
@TylerBrooker
@TylerBrooker 7 күн бұрын
I tried printing the ASCII character for 127, which in the table shows up as the 'DEL' character, but for some reason I got this symbol: ' ⌂ ' , known as the 'house' - what's going on here?
Reversing Strings (in C) and Divergent Thinking
13:15
Jacob Sorber
Рет қаралды 31 М.
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58
Little girl's dream of a giant teddy bear is about to come true #shorts
00:32
لقد سرقت حلوى القطن بشكل خفي لأصنع مصاصة🤫😎
00:33
Cool Tool SHORTS Arabic
Рет қаралды 26 МЛН
MISS CIRCLE STUDENTS BULLY ME!
00:12
Andreas Eskander
Рет қаралды 20 МЛН
Heartwarming Unity at School Event #shorts
00:19
Fabiosa Stories
Рет қаралды 25 МЛН
Header Issues: Guards, Name Mangling, and extern "C"
8:32
Jacob Sorber
Рет қаралды 76 М.
The What, How, and Why of Void Pointers in C and C++?
13:12
Jacob Sorber
Рет қаралды 52 М.
Be Careful When Using scanf() in C
12:22
NeuralNine
Рет қаралды 127 М.
Defining Constants. Should I use CONST or #DEFINE?
7:59
Jacob Sorber
Рет қаралды 56 М.
When do I use a union in C or C++, instead of a struct?
11:18
Jacob Sorber
Рет қаралды 68 М.
What's the Best Way to Copy a Struct in C and C++?
13:44
Jacob Sorber
Рет қаралды 33 М.
Null Terminated String Safety Issues | C Programming Tutorial
19:29
Portfolio Courses
Рет қаралды 3,5 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 158 М.
How to Implement a Tree in C
14:39
Jacob Sorber
Рет қаралды 93 М.
Little girl's dream of a giant teddy bear is about to come true #shorts
00:32