Ƙarshen yana nufin jeri na jeri inda aka tsara bytes zuwa manyan ƙimar lambobi lokacin da aka adana a ƙwaƙwalwar ajiya ko yayin watsawa. Manyan nau'ikan endianness guda biyu da suke wanzu sune babban endian da ƙaramin ɗanɗano. Babban endian shine mafi mahimmancin byte a cikin ƙaramin adireshin kuma ƙaramin endian shine mafi ƙarancin mahimmancin byte a cikin ƙaramin adireshin. A cikin shirye-shiryen C, jin daɗi yana da mahimmanci lokacin da kake karanta bayanan binary kai tsaye ba tare da yin amfani da masu aikin cirewa ba. Bincika mafita da cikakken ƙwararrun ƙwararrun lambar da aka bayar don gano ƙarshen tsarin. Bugu da ƙari, za ku koyi game da mahimmancin ɗakunan karatu da ayyukan da ke da hannu wajen magance wannan matsala mai rikitarwa.
#include<stdio.h> int main() { unsigned int i = 1; char *c = (char*)&i; if (*c) printf("Little endian"); else printf("Big endian"); return 0; }
Bayanin mataki-mataki na Code
Rubutun snippet ɗin da aka bayar an rubuta shi a cikin C, maƙasudi na gaba ɗaya, yaren shirye-shirye na tsari wanda zai ƙayyade ƙarshen tsarin.
Da farko, bari mu bincika #haɗa
Maɓalli na Aiki da Sauyawa
Na gaba, an bayyana babban aikin. Wannan ita ce wurin shiga kowane shirin C. A cikin wannan aikin, ana ayyana lamba i mara sa hannu kuma an fara farawa zuwa 1, kuma ana ayyana alamar 'c' kuma an fara farawa zuwa adireshin i.
Bayanin sharadi da ke biyo baya yana bincika ko baiti na farko a cikin char da aka nuna ta 'c' shine 1 ko 0. Idan 1 ne, tsarin yana da ɗan ƙaramin endian, in ba haka ba babban endian ne.
Wannan ƙayyadaddun bincike shine ainihin tushen shirin kuma shine dabaru da muke amfani da su don gano ƙayyadaddun tsarin.
Ana amfani da aikin printf don nuna ko dai "Little endian" ko "Big endian" bisa sakamakon binciken mu na sharadi. Yana cikin ɗakin karatu na stdio.h kuma ana amfani dashi don tsara kayan aiki.
Fahimtar Dakunan karatu
Stdio.h shine madaidaicin ɗakin karatu a cikin shirye-shiryen C wanda ya haɗa da ma'anar nau'ikan, macro da ayyuka don ayyuka kamar shigarwa / ayyukan fitarwa, samun damar fayil, sarrafa kirtani, da dai sauransu Yana taka muhimmiyar rawa wajen nuna fitarwa zuwa allon.
Fahimtar Nau'ukan Bayanai da Manufofi
A cikin shirye-shiryen C, masu nuni su ne masu canji waɗanda ke adana adiresoshin wasu masu canji. Anan, 'char *c' shine mai nuni ga hali.
Ana amfani da afaretan '&' don samun adireshin 'i' kuma sanya shi zuwa 'c'. Manufar wannan aiki shine don samun wakilcin matakin byte na ma'aunin ma'aunin lamba 'i' don bincika iyakarsa.
A taƙaice, gano ƙaƙƙarfan tsarin yana da mahimmanci a cikin wasu ƙananan ayyuka na shirye-shirye, kuma wannan lambar tana ba da hanya mai sauƙi don bincika ƙarancin ta amfani da yaren shirye-shiryen C. Bugu da ƙari, fahimtar ɗakunan karatu, ayyuka, nau'ikan bayanai da masu nuni da aka yi amfani da su a cikin wannan yanki na lambar zai kafa tushe mai ƙarfi don tafiyarku a cikin shirye-shiryen C.