Duniyar shirye-shirye a cikin C ta kasance mai arziฦi mai ban sha'awa kuma mai sarฦaฦฦiya, mai cike da manyan ayyuka waษanda ke biyan buฦatu daban-daban. ฦauka, alal misali, manufar girman tasha a cikin C. Ma'anar ta ta'allaka ne akan daidaita girman tashar tashar ko na'ura mai kwakwalwa a cikin harshen shirye-shiryen C. Wannan labarin yana zurfafa cikin tsari mai tsauri zuwa girman tasha a cikin C, yana ba da cikakken bayani mataki-mataki na lambar.
Don haka, me yasa girman tashar ke da mahimmanci? A cikin shirye-shiryen C, na'ura mai kwakwalwa ko tasha tana ba da hanyar sadarwa don mai amfani don mu'amala da shirin. Ana nuna masu sauye-sauye, nau'ikan bayanai, da sauran abubuwan da aka fitar a kan tashar. Yin la'akari da mahimmancinsa, samun tsabta da isasshen sarari akan na'ura mai kwakwalwa yana taimakawa wajen lura da abubuwan da aka fitar da kyau.
Fahimtar Girman Tasha
Zurfafa zurfafa cikin batun, fahimtar ainihin girman tasha a cikin C yana da mahimmanci. Girman tasha yana nufin adadin jere da abubuwan ginshiฦan da taga na'urar bidiyo za ta iya ษauka. Siffa ce da ke haษaka tsari da gabatar da abubuwan da ke bayyana kamanni da jin daษin na'urar wasan bidiyo.
Ayyuka kamar ioctl(), da aka ayyana a cikin ษakin karatu sys/ioctl.h, suna taka muhimmiyar rawa wajen maido da ma'auni na ฦarshe. Suna hulษa tare da sigogi na na'ura akan matakin mafi girma kuma suna ba da gudummawa sosai ga ayyukan I/O da yawa.
#include <sys/ioctl.h> #include <stdio.h> int main() { struct winsize w; ioctl(0, TIOCGWINSZ, &w); printf ("lines %dn", w.ws_row); printf ("columns %dn", w.ws_col); return 0; }
Maganin Girman Tasha
ฦayyade girman Terminal a cikin C za a iya samun nasara sosai ta amfani da aikin ioctl (). Aikin yana mu'amala da girman tasha kuma yana mayar da adadin layuka da ginshiฦai da ke akwai. Shirin yana amfani da kiran TIOCGWINSZ don buฦatar girman tasha kuma daga baya ya buga layin da aka samu da ฦimar shafi.
Kamar yadda aka gani a cikin samfurin code a sama, aikin ioctl() yana dawo da ma'aunin tasha kuma ana buga ma'aunin ta amfani da printf(). Ana amfani da wannan bayanan galibi don daidaita shimfidar abubuwan da aka fitar don mai amfani.
Bayanin Mataki-Ta-Taki na Code
Lambar tana da saukin kai. Anan ga matakin mataki-mataki:
A cikin layi na farko, ana shigo da dakunan karatu masu mahimmanci, sys/ioctl.h da stdio.h.
- sys/ioctl.h ana shigo da shi don aikin ioctl().
- stdio.h yana ba da ainihin shigarwa da ayyukan fitarwa
Bayan haka, an ayyana babban () aikin, yana nuna alamar shigarwar lambar. Anan ne shirin zai fara aiwatarwa.
In layi mai zuwa, struct winsize abu, w, an ayyana. Ana amfani da shi don yin mu'amala tare da aikin ioctl() da adana ma'aunin tasha.
Ana kiran aikin ioctl() tare da mahawara guda uku: 0, TIOCGWINSZ, da &w. Anan, 0 yana nufin bayanin fayil ษin don stdin, TIOCGWINSZ koyaushe ne wanda ke gaya wa ioctl don dawo da girman taga, kuma &w shine mai nuni ga tsarin winsize inda za'a adana girman.
Bayan yin hulษa tare da ma'auni na tashoshi ta amfani da ioctl, ana nuna girman tashar ( layuka da ginshiฦai ) ta amfani da printf (), yana kammala cikakken tsari.
Wannan misali yana kwatanta yadda ake ษaukowa da daidaita girman tasha a cikin C. Ilimin girman tasha ya tabbatar da cewa yana da matuฦar mahimmanci, yana taimakawa wajen ฦirฦirar mu'amalar abokantaka da mai amfani da haษaka damar gani na tashar.