sprintf() Function | C Programming Tutorial

  Рет қаралды 24,832

Portfolio Courses

Portfolio Courses

Күн бұрын

Пікірлер: 37
@andrewchen5345
@andrewchen5345 2 жыл бұрын
clear and concise. very good video
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you Andrew, glad to hear you enjoyed it! :-D
@yogeshchauhan9401
@yogeshchauhan9401 Жыл бұрын
Question:You have to take one int ,one float and one string as input then u have to add float and int values and then concatenate it with given string.How to approach this question?
@TSkateT666
@TSkateT666 2 жыл бұрын
Thanks, been using ur channel a lot lately!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Awesome, I'm very glad to hear that! :-D
@iamacar1017
@iamacar1017 2 жыл бұрын
Thanks a lot, super useful for something i am working on at the moment :)
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome, I'm glad to hear it was helpful for you! :-D
@bsykesbeats
@bsykesbeats 2 жыл бұрын
Great breakdown... at 3:45 why did it print garbage values after 10.5 if the for loop was i < length? Shouldn't it stop after 10.5?
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
That's a great question! 😀 So those weren't garbage values, those were actual 0s that were in the string. If you use: printf("Hello %d %f", 2, 10.5); You'll get something like this too: Hello 2 10.500000 It's just the way the %f placeholder works that it may print more decimal digits of precision than we really need. You can use %.2f instead of %f to limit it to 2 decimal digits of precision. 🙂
@bsykesbeats
@bsykesbeats 2 жыл бұрын
@@PortfolioCourses ohhh gotcha, makes sense! Thanks for the reply!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You’re welcome! :-)
@gustavopalma6172
@gustavopalma6172 Жыл бұрын
Hey! Thanks for the video, really well explained. I was wondering, what compiler you use in this video?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You’re welcome Gustavo! :-) In this video I am using the gcc compiler on a Mac, with the terminal. I am using Visual Studio Code as the text editor.
@gustavopalma6172
@gustavopalma6172 Жыл бұрын
@@PortfolioCourses appreciated! Please have a wonderful day!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
@@gustavopalma6172 You too! 🙂
@michaelbenard6758
@michaelbenard6758 Жыл бұрын
I have seen alot of your videos and are helpful, I have a little problem how would I get computer serial Number. system("wmic get bios serialnumber>sn.txt"); And store it in an array of character and then print it on screen.? I really need help with that.
@devdude7607
@devdude7607 2 жыл бұрын
Hi, does a regular printf() store it's value in the memory? If not then where does it eventually go?
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
It might be in memory while printf() is executing, but printf will print the data to the console/terminal/shell we call it as output. :-) Like in this video, we see the output from printf in the console.
@seyedehfatemehmousavi6784
@seyedehfatemehmousavi6784 2 жыл бұрын
thank you veryy muchh:)
@ilutus
@ilutus Жыл бұрын
God bless you, finally i got it
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I'm glad you figured it out! :-)
@hugo-garcia
@hugo-garcia Жыл бұрын
So sprintf can do the same as strcpy ?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Great question Hugo… it works in a pretty different way, but yes essentially we can use sprintf to do a strcpy (and a strcat, and maybe other operations too). :-)
@hugo-garcia
@hugo-garcia Жыл бұрын
@@PortfolioCourses Is it safer or better than strcpy ?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
strncpy() would definitely be safer than sprintf, because it uses an extra argument to make sure we don't write past the size of the destination char array, see: kzbin.info/www/bejne/iIKbgGRpqtmLh9k. Whereas with sprintf(), it's up to the programmer to ensure the resulting string is not larger than the char array used to store the string. It's harder to compare strcpy() and sprintf(), but I strongly suspect strcpy() would have better performance because ALL it does is copy a string, whereas sprintf() needs to look at the format string and determine how to "build the string" which should take more work. This would make an interesting performance comparison test. :-)
@mon0theist_tv
@mon0theist_tv 2 жыл бұрын
Super helpful, thank you
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You’re welcome Abdul-Hakeem! :-D
@pedrodeazeredonogueira9661
@pedrodeazeredonogueira9661 Жыл бұрын
i love you you saved my life
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I'm glad the video was helpful for you! :-)
@anthonymazzie4237
@anthonymazzie4237 2 жыл бұрын
great video
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you Anthony! :-D
@Eddie-df8fv
@Eddie-df8fv 2 жыл бұрын
Great voice for some reason it sounds a bit sped up though lol
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thanks Eddie, I don’t know why it would sound that way but good to know! :-)
@safeyamohamed3854
@safeyamohamed3854 Жыл бұрын
🤩
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I'm glad you enjoyed the video Safeya! :-)
@safeyamohamed3854
@safeyamohamed3854 Жыл бұрын
@@PortfolioCourses yeah so much
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Cool! :-)
If you don’t learn sprintf(), your code will hate you later
8:34
Programming Electronics Academy
Рет қаралды 52 М.
НАШЛА ДЕНЬГИ🙀@VERONIKAborsch
00:38
МишАня
Рет қаралды 2,9 МЛН
Friends make memories together part 2  | Trà Đặng #short #bestfriend #bff #tiktok
00:18
Fake watermelon by Secret Vlog
00:16
Secret Vlog
Рет қаралды 27 МЛН
strcpy() and strncpy() functions | C Programming Tutorial
8:15
Portfolio Courses
Рет қаралды 39 М.
How to parse a string in C (sscanf)
10:39
CodeVault
Рет қаралды 58 М.
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58
126 sprintf and snprintf   Write formatted string into character array
7:12
C Programming! scanf() VS fgets() VS gets() Which ones better?
6:29
The right way to define a C function with no arguments
4:29
Jacob Sorber
Рет қаралды 34 М.
Matlab: fprintf and sprintf (and also char at the end)
30:26
Neal Holtschulte
Рет қаралды 2,3 М.
Python Classes and Objects - OOP for Beginners
8:01
Python Simplified
Рет қаралды 560 М.
НАШЛА ДЕНЬГИ🙀@VERONIKAborsch
00:38
МишАня
Рет қаралды 2,9 МЛН