Тёмный

C Programming using getopt Tutorial in Linux 

theurbanpenguin
Подписаться 80 тыс.
Просмотров 54 тыс.
50% 1

Using the C Programming Language and getting input using getopt. If we have used the command line at we should be used to providing command line options such as ping -c or ls -l; the options -l, -c etc can be read from within the program using the getopt function from the getopt.h header file. For more information you can read the man page , man 3 getopt if you are using Linux. Using the Raspbian OS on the Raspberry Pi this tutorial looks at creating a program in C that can be used to convert temperatures from Centigrade to Fahrenheit and vice versa. We will use getopt to search for the options -c and -f to ensure that the correct calculation is applied.

Опубликовано:

 

7 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 49   
@Joao-oj6bn
@Joao-oj6bn Год назад
Even after 8 years still the best video i can find about this subject, thanks!
@TheLordoftheDarkness
@TheLordoftheDarkness 4 года назад
Thank you so much for explaining things slowly. All other tutorials I found on the Internet directly went to the ':' thing leaving me clueless. You video was very well presented on the other hand. Again thanks.
@theurbanpenguin
@theurbanpenguin 4 года назад
Glad it worked for you
@dampdigits
@dampdigits Год назад
Thank You! I was having difficulty to understand the concept from articles.
@theurbanpenguin
@theurbanpenguin Год назад
Thanks
@dampdigits
@dampdigits Год назад
@@theurbanpenguin why use getopt.h instead of unistd.h header file
@NeoColossus1020
@NeoColossus1020 10 лет назад
Keep up the good work. I browse your videos from time to time and you always have a very direct/simple approach to explaining the concepts covered.
@ДимаПетров-н3ц
@ДимаПетров-н3ц 5 месяцев назад
Bro, super good, thank you. I was writing copy of grep and don't know how to parse multiple flags so easy!
@N0AGI
@N0AGI 9 лет назад
Andrew - great video. Your truly passionate about sharing your knowledge. Keep up the great work. I learn a lot from watching your videos. Especially the C programming on RASPI. thanks, 73, N0AGI, Nagi
@multivalfran
@multivalfran 2 года назад
Great video. Absolutely everything I was looking for. Thank you very much
@theurbanpenguin
@theurbanpenguin 2 года назад
awesome
@MrMits92
@MrMits92 2 года назад
amazing explanation ! Great video ! Big thx !
@heisserpriester7371
@heisserpriester7371 Год назад
Loved that video! Thanks so much, you helped a lot!
@theurbanpenguin
@theurbanpenguin Год назад
Great
@trudyandgeorge
@trudyandgeorge 10 лет назад
Mate, your videos are great. I love them.
@JasonKT13
@JasonKT13 4 года назад
thank you for providing this information, very useful
@joemeno123
@joemeno123 10 лет назад
your videos are very useful. Keep up the good work, mate! :)
@diogenisstogiannaris3841
@diogenisstogiannaris3841 2 года назад
Great video! getopt made simple !!!
@PierreLombardini
@PierreLombardini 9 лет назад
this was perfect ! really easy to follow :)
@gothfrog69
@gothfrog69 Год назад
That was awesome!
@theurbanpenguin
@theurbanpenguin Год назад
Thank you
@yogpooja-vq1pp
@yogpooja-vq1pp 4 года назад
very well explained .. thank you
@theurbanpenguin
@theurbanpenguin 4 года назад
Thanks for commentiing
@brianna8587
@brianna8587 3 года назад
YOU SAVED ME
@williamsilva8779
@williamsilva8779 2 года назад
thank you
@amos660
@amos660 2 года назад
beautiful.
@theurbanpenguin
@theurbanpenguin 2 года назад
Nice, comment thank you
@chandrashekharjp3044
@chandrashekharjp3044 6 лет назад
Great Tutorial :)
@shrutiambashtha6196
@shrutiambashtha6196 4 года назад
Thank u sooooooo much ☺️☺️☺️
@D3rMesaa
@D3rMesaa 3 года назад
Ja geil, da hat der Kranzlmüller ja lang gesucht, bis er seine Aufgabe gefunden hat
@kumaravelrajan
@kumaravelrajan 3 года назад
Perfect.
@shiftrip
@shiftrip 2 года назад
Great video. I'm a c novice so here's my question - if option is int, why does compiler allow us to option=getopt(argc....) when what we are reading from command line are characters (c or f) and not integer numbers?
@codesk5653
@codesk5653 4 года назад
Hi there... Thank for this video, it is extremely easy to follow along and understand. However, if the input is ./temp -fc the program takes 'c' as the ...How would I ensure that it still checks the flags/options in this case?
@FERCHOLO0730
@FERCHOLO0730 3 года назад
awesome! however I played it 1.5x XD
@rafidm6263
@rafidm6263 10 лет назад
is there a particular reason why the flags aren't boolean?
@miguelboxer177
@miguelboxer177 5 лет назад
Why did you increment c and f flag?
@shyngysbek6907
@shyngysbek6907 24 дня назад
option is declared as an integer but assigned a char symbol from the getopt and used in switch()? What?
@shyngysbek6907
@shyngysbek6907 24 дня назад
ok, getopt returns an integer but it is represented as a char by its ASCII value
@hro688
@hro688 6 лет назад
спасибо, бро! Сними видео про getopt_long(), плизки! ставлю лайкос! успехов!
@samehmouldi2289
@samehmouldi2289 5 лет назад
how does the program know that cflag and flag reffer to the number of options please ?
@SepidehAsadi1
@SepidehAsadi1 7 лет назад
Thanks! It would be useful if you provide the text of code below the video link.
@Submersed24
@Submersed24 7 лет назад
char **argv is the same as char *argv[] right?
@hro688
@hro688 6 лет назад
yes ofc. ** is the pointer to pointer, so char ** and char * [] is an array (or a pointer on the first element of this array) of "c-style" strings, because every string is c is just an array of char symbols with the 0 symbol at the end.
@timgoppelsroeder121
@timgoppelsroeder121 3 года назад
that penguin is the shit!!!!!
@luciomorra6174
@luciomorra6174 4 года назад
Didnt understand the fflag & cflag ...:(
@piacare
@piacare 10 лет назад
8:56 did you start recording at night? Haha
@Isaac-eh6uu
@Isaac-eh6uu 2 года назад
I hate getopt
@xintongma2976
@xintongma2976 2 года назад
thank you
@theurbanpenguin
@theurbanpenguin 2 года назад
Thanks
Далее
Essentials: Pointer Power! - Computerphile
20:00
Просмотров 464 тыс.
C Programming: Makefiles
44:21
Просмотров 262 тыс.
Become a shell wizard in ~12 mins
12:25
Просмотров 251 тыс.
Why Linux Is Better For Programming
13:32
Просмотров 2,8 млн
Master Pointers in C:  10X Your C Coding!
14:12
Просмотров 312 тыс.
why do header files even exist?
10:53
Просмотров 412 тыс.
The mind behind Linux | Linus Torvalds | TED
21:31