C (chiyowoyero cha mapulogalamu)

C (yakuzunulika kuti  – nga ni chilembo c) ni chiyowoyero cha mapulogalamu ya chilato chambula kukazikika. Likapangika mu 1970s na Dennis Ritchie ndipo yikulutilira kugwiliskirika nchito comene ndiposo kukhaska ŵanthu ŵanandi. Mu ka kwatiro, kaŵiro ka C kakulongora makora nkhongono za ma CPU. Likusanga nchito yakukhalilira mu vilemba vya udesi vya Ndondomeko Zilala (chomene-mene me ma kenele), sigilo za makina, na ndondomeko zidikanyi, kweni kugwiliskira ntchito kwake mu mapulogalamu gha chilato chikhazikiki kakukhila. C yikugwiriskirika nchito comene mu kazengekero ka makompyuta ivyo vikufuma ku ma makompyuta gha utana ghakuru nkhanira mpaka ma microcontrollers na embedded systems ghachoko chomene-mene.

Nga chiyowoyelo cha ma pulogramu icho chikalondezgapo pa chiyowoyelo cha ma pulogramu cha B, C wakapangika pakwamba ku Bell Labs na Ritchie pakati pa 1972 na 1973 kuti ŵazenge vyakugwiriskira nchito ivyo vikugwira ntchito pa Unix. Likagwiriskirika nchito pa Kukhazikiskaso kenele ya Ndondomeko Yilala Ya Unix. Mu vilimika vya m’ma 1980, C wakamba kutchuka pachokopachoko. Icho chazgoka chimoza mwa viyowoyero ivyo vikugwiriskirika nchito chomene pakupanga mapulogiramu, na msutuli wa C ukusangika pafupifupi pa mazengero gha makompyuta ghose gha mazuŵa ghano na Ndondomeko Zilala Zose. Buku la The C Programming Language (Chiyowoyero cha C), ilo likalembeka pamoza na uyo wakalemba chiyowoyero cha C pakwambilila penecho, yikateŵetera kwa vilimika vinandi nga ni muyezo wa ciyowoyero cha C chakufikapo. C yaŵikika pa mlingo kufuma mu 1989 na wupu wa American National Standards Institute (ANSI) na, mwakulondezgapo, mwakukolelana na ŵa International Organization for Standardization (ISO) na ŵa International Electrotechnical Commission (IEC).

C ni chiyowoyero cha Kulangula mwandondomeko, yakuzomela kulemba ma pulogalamu ghakundandikwa, lexical variable scope, na Kawerezgawerezga, pamoza na kalembero kambula kusintha (ka ma pulogalamu). yikakwatika kuti yi sutulikenge kuti yipe chizomelezgo cha pafupi na pasi cha kukhwaska memore na mazengero gha viyowoyero ghakukolelana makola yene kwa malangulo gha makina, vyose ivi na ufighiliro wa runtime wakukhira. Nangauli na nkhongono zake zapasi, chiyowoyero ichi chikapangika kuti chikhozgere mapulogiramu ghakupambanapambana. Pulogalamu ya C ya Kulondezga miyezgo yakulembeka na chirato cha upusu wa kunyamulika yingasutulilika kuti yende pa ma pulatifomu ghakupambanapambana gha ma kompyuta na Ndondomeko Zilala nakusintha kudoko waka kwa malembero gha udesi ghakhe.

Kwamba 2000, C nyengo zose yaŵa pakati pa viyowoyero vinayi vyapachanya na TIOBE index, icho ntchipimo cha kutchuka kwa viyowoyero vyakupanga mapulogalamu.

 Kuwoneseska mwakudumura 

C ni chiyowoyero cha kulangura, cha ndondomeko mu udawuko wa ALGOL. yili na kalembero kambula kusintha. mu C, vilembero videsi vyakuthyeka vyose vikujalilika mu ma subroutines (yakuchemekaso ma "function", kweni mu ka ng'anamuliro ka functional programming chara). Function parameters ghakupizgika kwendela value, nangawuri ma arrays ghakupizgika nga ma pointer, ndiko kuti keyala ya chinthu cha kwamba mu array iyo. Pass-by-reference yikutetezgeleka mu C pakupizga nkhanira-nkhanira ma pointer kwa chinthu icho chikupangika reference.

Program source text ya C ni vilembo vya udesi vya free-form. Ma Semicolons ghakutheleska ma statements, apo ma curly braces ghakugwiliskika kugawa ma statements mu ma blocks.

Chiyowoyelo cha C chikulongolaso vimanyisko ivi:
 Chiyowoyero ichi chili na nambara yichoko, yakukhazikika ya mazgu ghakuzirwa, kusazgapo gulu lose la ma control flow gha primitive: if/else(panji nthe/pala apo cha), for(ya), do/while(chita nthe/pala), while(apo), na switch(sinthiska). Mazina ghakusoleka na wolemba yakupambaniskika yayi na mazgu ghakuzirwa gha C na mtundu uliwose wa sigil.
 Lili na nambala yikuru ya luso-lakupenda, bitwise, na ma operator gha logic
 Ma assignment yakujumpha yimoza yangachitika mu statement ghamoza.
 ma Function:
 Value ya Function yinga yingazelezgeka, para yikukhumbikwa yayi.
 Function na pointer ya yikuzomela run-time polymorphism ya ad hoc.
 Functions vingalongosoreka yayi mu scope ya lexical ya ma functions yanyakhe.
 Ma Variable lingalongosoreka mukati mwa Function, pamoza na scope.
 Function yingajichema yekha, ntheura recursion yikufighililika.
 Kulemba Data kuli kwa static, kweni yikuchichizgika mwakufowoka; data yose yili na type, kweni ma implicit conversions ghangaŵapo.
 Ma types yakulongosoreka na mwene (typedef) na ya kusazga yanandi-yanandi yangachitika.
 Mitundu ya data yakusazgikira yakupambanapambana (struct) yikuzomerezga kuti vinthu vyakukhwaskana na data visangike na kugaŵika nga ni chigaŵa. Ivyo vili mu structs yose vingayaniskika yayi na kugwiliskira nchito opareshoni yimoza yakupangika (vinthu vikwenera kuyaniskika paŵekha).
 Union ni chizengero icho chili na viŵaro vyakukhwaskana; likuzomerezga mitundu yinandi ya data kuti yigaŵane malo ghamoza ghakukumbukira.
 ma Array Enumerated types nga machitiko kwendela lizgo lakuzirwa la enum. Iwo ŵakusinthika mwawanangwa na manambara gha integer.
 ma Enumerated types nga machitiko kwendela lizgo lakuzirwa la enum. Iwo ŵakusinthika mwawanangwa na manambara gha integer.
 ma Strings ni ma data type payekha yayi, kweni yakukhazikiskika nga null-terminated character arrays.
 Kufika pa mlingo wapasi wa memory ya kompyuta nkhwamacitiko mwa kusintha maadiresi gha makina kuŵa ma pointer.
 ma Procedures (ma subroutines agho ghakuwezga cha ma value) ni nkhani yapadera ya Fuction, na return type yambula kanthu ya void.
 Memore yingapika kwa pulogalamu kwendela ma calls kwa ma library routines.
 Preprocessor yikulongosora vinthu vikuruvikuru, kuŵikamo fayilo ya source code, na kuŵika vinthu pamoza.
 Pali mtundu wakwamba wa modularity: mafayilo ghangapangika padera na kukolerana pamoza, na kulaŵilira ivyo vikuchitika na vinthu vya data ivyo vikuwoneka ku mafayilo ghanyake kwizira mu mikhaliro yakukhazikika na yakunja.
 Ntchito zakusuzga nga ni I/O, kugwiliskira ntchito vingwe, na masamu vikupelekeka nyengo zose ku ndondomeko za layibulare.
 Khodi ilo likupangika pamanyuma pa kuwunganya lili na vyakukhumbikwa vyambura kusuzga pa pulatifomu iyo yili pasi, ivyo vikupangiska kuti liŵe lakukwana pakupanga ndondomeko zakugwiliskira ntchito na kugwiliskira ntchito mu ndondomeko zakuŵikika.

Nangauli C yikusazgapo yayi vinthu vinyake ivyo vikusangika mu viyowoyero vinyake. (nthe object orientation na garbage collection), ivi vingakwaniskika panji kuyezgeleka, kanandi kwizira mu kugwiliskira nchito malaibulale gha kuwaro  (nthe GLib Object System panjiso Boehm garbage collector).

 Ubale na viyowoyero vinyake 

Viyowoyero vinandi vya pamanyuma vikabwereka mwaluŵiro panji mwambura kumanyikwa kufuma ku C, nthe C++, C#, C shell ya Unix, D, Go, Java, JavaScript (kusazgapo transpilers), Julia, Limbo, LPC, Objective-C, Perl, PHP, Python, Ruby, Rust, Swift, Verilog na SystemVerilog (viyowoyero vyakulongosora vya hardware).  Viyowoyero ivi vyakopa vinandi mwa ma control structures yawo na vinyake mwa vyakuzirwa kufuma ku C. Ŵanandi ŵa iwo ŵakuwoneskaso kuti ŵakuyana chomene malango gha kalembero na C, ndipo ŵakutemwa kuphatikizapo mazgu ghakumanyikwa na mazgu gha C na ndondomeko za mtundu wakubisika, viyerezgero vya data, na semantics ivyo vingaŵa vyakupambana comene.

 Mbiri 

 Kukwatika kwakwamba 
+Timeline of C language Year Informalname Officialstandard 1972 first release  1978 K&R C  1989,1990 ANSI C, C89,ISO C, C90 ANSI X3.159-1989ISO/IEC 9899:1990 1999 C99, C9X ISO/IEC 9899:1999 2011 C11, C1X ISO/IEC 9899:2011 2018 C17, C18 ISO/IEC 9899:2018 2024 C23, C2X ISO/IEC 9899:2024 Future C2Y 

Chiyambi cha C chikukolerana chomene na kupanga ndondomeko yakugwira ntchito Ndondomeko yilala ya Unix, iyo yikakhazikiska pakwamba mu chiyowoyero cha assembly pa PDP-7 na Dennis Ritchie na Ken Thompson, kusazgapo maghanoghano ghanandi kufuma ku ŵanyawo.  Paumaliro, ŵakaghanaghana kuti ŵaŵike pulogiramu iyi ku PDP-11. Mtundu wakwamba wa PDP-11 wa Unix ukapangikaso mu chiyowoyero cha assembly.

 B 

Thompson wakakhumbanga chiyowoyero cha pulogiramu yakupangira vinthu vyakugwiriskira ntchito pa pulatifomu yiphya. Wakayezga dankha kulemba Fortran compiler, kweni mwaluŵiro wakaleka fundo iyi ndipo m’malo mwake wakapanga mtundu wakudumulika wa systems programming language yakuchekeka BCPL. ulongosora kwakuzomerezgeka kwa BCPL kukaŵako yayi pa nyengo iyo, andipo Thompson wakasintha mazgu ghake kuti ghaŵe ghambura ‘mazgu ghanandi’ ndiposo ghakuyana waka na ALGOL yakupepuka iyo yikumanyikwa kuti SMALGOL. Wakachema chakufumapo B, kuchilongosora kuti "BCPL semantics na mazgu ghanandi gha SMALGOL". Nge BCPL, B yikakaŵa na bootstrapping kuti viŵe vyambura kusuzga kutumizga ku makina ghaphya. Paumaliro, vipangizo vichoko waka vikalembeka mu B chifukwa vikaŵa vyakuchedwa chomene ndipo vikatondeka kusanga mwaŵi wa vinthu vya PDP-11 nga ni addressability ya byte.

 B yiphya na C yakwamba 
Mu 1971 Ritchie wakamba kusintha B, kuti wagwiriskirenge nchito vinthu vya PDP-11 yankhongono comene. Kuwonjezerapo kwakuzirwa kukaŵa mtundu wa data ya malembo. Wakacema ici kuti B Muphya (NB).  Thompson wakamba kugwiliskira ntchito NB pakulemba kernel ya Unix kernel, ndipo ivyo wakakhumbanga vikapangiska kuti chiyowoyero chiŵe chiwemi.  Kufika mu 1972, mitundu yakusambazga yikasazgikira ku chiyowoyero cha NB: NB yikaŵa na magulu gha int na char. Pointers, luso la kupanga pointers ku mitundu yinyake, ma arrays gha mitundu yose, na mitundu iyo yikwenera kuwelera kufuma ku milimo vyose vikasazgikirapo. Ma arrays mukati mwa mazgu ghakazgoka vimanyikwiro. Ŵakalemba buku liphya lakuwunganya vinthu, ndipo chiyowoyero ichi chikasintha zina kuŵa C.

C compiler na vinyake ivyo vikapangika nayo vikasazgikika mu Version 2 Unix, uwo ukumanyikwaso kuti Research Unix.

 Kulembaso ma Zengero na kenero ya Unix 
Pa Version 4 Unix, iyo yikafumiskika mu Novembala 1973, Unix kernel yikaŵikikaso mu uphya mu C. Pa nyengo iyi, chiyowoyero cha C chikaŵa kuti chasanga vinthu vinyake vyankhongono nga ni mitundu struct.

Preprocessor yikayambiskika mu 1973 pakuchichizga na Alan Snyder ndiposo chifukwa cha kumanya kuti nthowa zakuŵikamo mafayilo izo zili mu BCPL na PL/I. Mtundu wake wakwamba uwo ukapelekeka ukaŵa waka na mafayilo na vinyake vyambura kusuzga vyakusintha: #include na #define. Pamanyuma pa nyengo yichoko waka, likasazgikirapo, chomenechomene na Mike Lesk ndipo pamanyuma na John Reiser, kuti ŵasazgireko macros na mphindano na kuwunganya kwakuzomerezgeka.

Unix yikaŵa yimoza mwa ma kernel ghakwamba ghakugwiliskira ntchito mu chiyowoyero chinyake padera pa msonkhano . Vinthu ivyo vikachitika pakwamba vikusazgapo ndondomeko ya Multics (iyo yikalembeka mu PL/I ) na Pulogalamu Yakulongozga (MCP) ya Burroughs B5000 (iyo yikalembeka mu ALGOL ) mu 1961. Pafupifupi mu 1977, Ritchie na Stephen C. Johnson ŵakasinthaso vinthu vinyake kuti . chiyowoyero kuti chiwovwire kunyamulika kwa dongosolo la Unix. Johnson's Portable C Compiler ndiyo yikaŵa maziko ghakuŵika C pa mapulatifomu ghaphya. (Note: The PDF is an OCR scan of the original, and contains a rendering of "IBM 370" as "IBM 310".)

 K&R C 
IMu 1978, Brian Kernighan na Dennis Ritchie ŵakasindikizga buku lakwamba la Chiyowoyero cha C .  Buku ili likamanyikwa kuti K&R kufuma ku vimanyikwiro vyakwamba vya awo ŵakalemba, ndipo likateŵetera kwa vilimika vinandi nga ni chiyowoyero chambura kumanyikwa . Mtundu wa C uwo ukulongosora ukuchemeka kuti " K&R C ". Pakuti iyi yikafumiskika mu 1978, sono yikuchemekaso kuti C78 .  Buku lachiŵiri la  likulongosora vya ANSI C standard iyo yikapangika pamanyuma, iyo yikulongosoreka musi umu.

K&R yikayambiska viyowoyero vinandi:
 Standard I/O library
 long int mtundu wa data
 unsigned int mtundu wa data
 Compound assignment operators of the form =op (such as =-) were changed to the form op= (that is, -=) to remove the semantic ambiguity created by constructs such as i=-10, which had been interpreted as i =- 10 (decrement i by 10) instead of the possibly intended i = -10 (let i be −10).

Nangauli panyuma pakuti 1989 ANSI standard yalembeka, kwa vilimika vinandi K&R C yikaŵa kuti yichali kuwoneka kuti ni " lowest common denominator " iyo ŵakupanga mapulogiramu gha C ŵakajikanizganga para ŵakukhumba kunyamura chomene, chifukwa mabuku ghanandi ghakale ghakaŵa kuti ghachali kugwiliskirika ntchito, ndiposo chifukwa chakuti K&R yikalembeka makora . C khodi ingaŵa yakuzomerezgeka Standard C nayo.

Mu mitundu yakwamba ya C, milimo pera iyo yikuweleska mitundu yinyake padera pa iyo intyikwenera kupharazgika usange yikugwiriskirika nchito pambere nchito yindalongosoreke; ntchito izo zikugwiriskirika nchito kwambura kupharazga dankha zikaŵa kuti zikuwelera mtundu int.

Mwa chiyezgelelo:

long some_function(); /* This is a function declaration, so the compiler can know the name and return type of this function. */
/* int */ other_function(); /* Another function declaration.  Because this is an early version of C, there is an implicit 'int' type here.  A comment shows where the explicit 'int' type specifier would be required in later versions. */

/* int */ calling_function() /* This is a function definition, including the body of the code following in the { curly brackets }. Because no return type is specified, the function implicitly returns an 'int' in this early version of C. */
{
    long test1;
    register /* int */ test2; /* Again, note that 'int' is not required here. The 'int' type specifier */
                              /* in the comment would be required in later versions of C. */
                              /* The 'register' keyword indicates to the compiler that this variable should */
                              /* ideally be stored in a register as opposed to within the stack frame. */
    test1 = some_function();
    if (test1 > 1)
          test2 = 0;
    else
          test2 = other_function();
    return test2;
}

Mtundu intwa vimanyikwiro ivyo vikuyowoyeka vingaŵa kuti vyalekeka mu K&R C, kweni vikukhumbikwa mu vigaŵa vyakulondezgapo.

Pakuti vipharazgo vya ntchito vya K&R vikaŵavya uthenga uliwose wakukhwaskana na mphindano za ntchito, kuwoneseska kwa mtundu wa parameter ya ntchito kukachitika yayi, nangauli ŵanyake awo ŵakulemba mabuku ŵangapeleka uthenga wakuchenjezga usange ntchito ya ku malo ghawo yikachemeka na nambara yakubudika ya mphindano, panji usange yikuchemeka mwakupambanapambana ku ntchito yakuwalo . ŵakagwiliskiranga ntchito manambara panji mitundu yakupambanapambana ya mphindano. Vipangizo vyapadera nga ni Unix's lint utility vikapangika ivyo (pakati pa vinyake) vingawona usange ntchito yikugwiriskirika nchito mwakuyana mu mafayilo ghanandi ghakufumapo.

Mu vyaka ivyo vikalondezgapo panyuma pa kupharazgika kwa K&R C, vinthu vinandi vikasazgikira ku chiyowoyero ichi, ivyo vikakhozgeka na ŵakuwunganya kufuma ku AT&T (makamaka PCC  ) na ŵanyake awo ŵakaguliskanga. Vinthu ivi vikaŵa:
 void functions (i.e., function zambura value yakuwelera)
 functions returning struct or union types (previously only a single pointer, integer or float could be returned)
 assignment for struct data types
 enumerated types (kale, vilongosolero vya preprocessor vya mtengo wakukhazikika wa integer vikagwiriskirika nchito, mwachiyelezgero #define GREEN 3)

Chiŵerengero chikuru cha kusazgirako na kusoŵa kwa mgwirizano pa layibulare yakumanyikwa , pamoza na kutchuka kwa chiyowoyero ndiposo kuti nanga mbakulemba Unix ŵakakwaniska yayi kukhazikiska makora mazgu gha K&R, vikapangiska kuti paŵe kukhumbikwa kwa kuŵika vinthu mwakuyana.

 ANSI C na ISO C 

Mu vilimika vya kumanyuma vya m’ma 1970 na 1980, mitundu ya C yikaŵikika pa ma computer ghakupambambana nthe mainframe computers, minicomputers, na microcomputers, kusazgapo IBM PC, apo ŵanthu ŵakamba kuyimanya chomene.

Mu 1983, ŵa American National Standards Institute (ANSI) ŵakapanga komiti, X3J11, kuti yiŵikepo ndondomeko yakumanyikwa ya C. X3J11 yikakhazikika pa ndondomeko ya C pa kukhazikiska kwa Unix; kweni chigaŵa cha layibulare ya Unix C icho chikunyamulika yayi chikapelekeka ku IEEE working group 1003 kuti chiŵe maziko gha 1988 POSIX standard. Mu 1989, muyezo wa C ukazomerezgeka nga ni ANSI X3.159-1989 "Chiyowoyero cha C". Mtundu uwu wa chiyowoyero ichi kanandi ukuchemeka kuti ANSI C , Standard C, panji nyengo zinyake C89.

Mu 1990, ANSI C standard (na kusintha kwa mawonekero) yikazomerezgeka na wupu wa pa charu chose (ISO) nga ni ISO / IEC 9899: 1990, iyo nyengo zinyake yikuchemeka C90. Ntheura, mazgu ghakuti "C89" na "C90" ghakung'anamura chiyowoyero chimoza cha pulogiramu.

ANSI, nga ni mabungwe ghanyake ghakukhwaskana na malango gha charu, ghakupangaso yayi malango gha C paŵekha, kweni ghakulondezga malango gha C gha pa charu chose, agho ghakusungika na gulu la ntchito ISO / IEC JTC1 / SC22 / WG14. Kuzomerezga kwa charu chose kwa kusintha kwa ndondomeko ya pa charu chose kanandi kukuchitika mu chaka chimoza kufuma apo ISO yikasindikizgikira.

Chimoza mwa vigaŵa vya ndondomeko ya C standardization chikaŵa chakuti ŵapange superset ya K&R C, kusazgapo vinthu vinandi ivyo vikayambiskika pamanyuma pake vyambura kumanyikwa. Komiti ya vipimo yikasazgaposo vinthu vinyake vinandi nga ni viyezgelero vya nchito (vyakubwereka kufuma ku C ++), voidvimanyikwiro, wovwiri wa vimanyikwiro vya pa caru cose na malo , na kukhozga preprocessor. Nangauli mazgu ghakulembeka gha parameter declarations ghakasazgikirapo kuti ghaŵe na mtundu uwo ukugwiriskirika ncito mu C ++, K&R interface yikalutilira kuzomerezgeka, kuti yikolerane na source code iyo yikaŵapo.

C89 yikukhozgeka na ŵakulemba C ŵasono, ndipo makhodi ghanandi gha mazuŵa ghano gha C ghakukhazikika pa iyo. Pulogalamu yiliyose iyo yikulembeka mu Standard C pera ndiposo kwambura kughanaghana kuti yikuthemba pa hardware yizamuchitika makora pa pulatifomu yiliyose iyo yili na C yakukolerana, mu mphaka ya vyakugwiriskira ntchito vyake. Kwambura kucenjera nthena, mapulogiramu ghangawunganya waka pa pulatifomu yinyake panji na munthu munyake uyo wakuwunganya, cifukwa ca, mwaciyelezgero, kugwiliskira nchito malaibulale ghambura kumanyikwa, nga ni malaibulale gha GUI , panji kuthemba pa mikhaliro ya munthu uyo ​​wakuwunganya panji pa pulatifomu nga ni . nga ni kukula kwa mitundu ya data na byte endianness.

Mu ivi vingachitika vakuti khodi yikwenera kuŵikika pamoza na ŵakulemba awo ŵakulondezga malango panji ŵa K&R C, __STDC__macro yingagwiliskirika nchito kuti yigaŵire khodi mu vigaŵa vya Standard na K&R kuti yileke kugwiliskirika nchito pa K&R C-based compiler ya vinthu ivyo vikusangika mu Standard pera . C.

Pamanyuma pa ndondomeko ya ANSI / ISO standardization, chiyowoyero cha C chikalutilira kuŵa chambura kusintha kwa vyaka vinandi. Mu 1995, kusintha kwa malango 1 ku 1990 C standard (ISO/IEC 9899/AMD1:1995, iyo yikumanyikwa mwambura kumanyikwa kuti C95) kukafumiskika, kuti ŵanozge vinyake na kusazgirako wovwiri ukuru ku vimanyikwiro vya pa caru cose.

 C99 

Muyezo wa C ukasinthikaso kuumaliro wa vilimika vya m'ma 1990, ndipo ukapangiska kuti ISO/IEC 9899:1999 yilembeke mu 1999, iyo yikuchemeka kuti " C99 ". Kufuma nyengo iyo, likasinthika katatu na Technical Corrigenda. 

C99 wakayambiska vinthu vinandi viphya, kusazgapo milimo ya mu mzere , mitundu yinandi yiphya ya data (kusazgapo long long intna complexmtundu wakuyimira manambara ghakusuzga ), ma array gha utali wakusinthasintha na ŵabali ŵa ma array ghakusinthasintha , wovwiri wakukhozga wa IEEE 754 floating point, wovwiri wa variadic macros (macros of variable ). arity ), na kukhozgera vyakuyowoya vya mzere umoza ivyo vikwamba na //, nga umo vikuŵira mu . BCPL panji C ++. Vinandi mwa vinthu ivi vikaŵa kuti vyaŵikika kale nga ni vyakuwonjezera mu ma C compilers ghanandi.

C99 ndiyo yikukolerana chomene na C90, kweni yikukhozga chomene mu nthowa zinyake; makamaka, chipharazgo icho chikusoŵa mtundu wakulongosora intchilijeso mwachindunji. Macro yakumanyikwa __STDC_VERSION__yikulongosoreka na mtengo 199901Lkuti yilongore kuti wovwiri wa C99 ulipo. GCC , Solaris Studio , na ŵanyake awo ŵakulemba C sono [ nyengo wuli? ] vikovwira vinandi panji vyose ivyo vili mu C99. C compiler mu Microsoft Visual C++ , nangauli, wakugwiriskira ncito muyezo wa C89 na vigaŵa vya C99 ivyo vikukhumbikwa kuti vikolerane na C++11 .  [ vikukhumbikwira kusintha ]

Kusazgirapo apa, muyezo wa C99 ukukhumba wovwiri wa vimanyikwiro vyakugwiriskira ncito Unicode mu mtundu wa malembo ghakucimbira (mwaciyelezgero \u0040panji \U0001f431) ndipo ukuyowoya wovwiri wa mazina gha Unicode ghambura kupangika.

 C11 

Ntchito yikamba mu 2007 pa kusintha kunyake kwa C standard, iyo yikuchemeka mwambura kumanyikwa kuti "C1X" m'paka apo yikasindikizgika mwakuzomerezgeka na ISO / IEC 9899:2011 pa Disembala 8, 2011. Komiti ya C standards yikazomerezga malango ghakuchepeska kuzomerezga vinthu viphya ivyo vikaŵa kuti vindachitike . ŵayezgeka na kukhazikiska uko kulipo.

C11 standard yikusazgapo vinthu vinandi viphya ku C na layibulare, kusazgapo mtundu wa generic macros, vigaŵa vyambura kumanyikwa, wovwiri wa Unicode wakunozga, ntchito za atomiki, kuŵika vingwe vinandi, na ntchito zakuwonera mphaka. Iwo ukupangiskaso kuti vigaŵa vinyake vya layibulare ya C99 iyo yilipo viŵe vyakusankha, ndipo vikupangiska kuti viŵe vyakukolerana na C ++. Macro yakumanyikwa __STDC_VERSION__yikulongosoreka kuti 201112Lyikulongora kuti wovwiri wa C11 ulipo.

 C17 

C17 ni zina lambura kumanyikwa la ISO / IEC 9899: 2018, ilo likumanyikwa na chiyowoyero cha C icho chikasindikizgika mu Juni 2018. Likulongosora yayi vinthu viphya vya chiyowoyero, likulongosora waka vyaukadaulo, na kulongosora ivyo vikubudika mu C11. Macro yakumanyikwa __STDC_VERSION__yikulongosoreka kuti 201710Lyikulongora kuti wovwiri wa C17 ulipo.

 C23 

C23 ni zina lambura kumanyikwa la chiyowoyero chikuru cha C chasono. Iwo ukamanyikwanga mwambura kumanyikwa kuti "C2X" kwizira mu kukura kwake kunandi. C23 yikasindikizgika mu Okutobala 2024 nga ni ISO / IEC 9899: 2024.  Macro yakumanyikwa __STDC_VERSION__yikulongosoreka kuti 202311Lyikulongora kuti wovwiri wa C23 ulipo.

 C2Y 
C2Y ni zina lambura kumanyikwa la chiyowoyero chikuru cha C, pamanyuma pa C23 (C2X), icho chikugomezga kuti chizamufumiskika pamanyuma mu vyaka khumi vya 2020, ntheura '2' mu "C2Y". Mundandanda wakwamba wa C2Y ukafumiskika mu Febuluwale 2024 nga ni N3220 na gulu lakugwira ntchito la ISO / IEC JTC1 / SC22 / WG14.

 C ya Embedded 

Mu mbiri, mapulogalamu gha C ghakuŵikika ghakukhumba kusazgirako kwambura kumanyikwa ku chiyowoyero cha C kuti ghawovwire vinthu vyakuziziswa nga ni masamu ghakukhazikika , mabanki ghanandi ghakupambanapambana ghakukumbukira , na ntchito zakwamba za I / O.

Mu 2008, Komiti ya C Standards yikasindikizga lipoti la luso ilo likasazgirako chiyowoyero cha C  kuti limazge nkhani izi mwa kupereka fundo yakuyana kuti vyose ivyo vikugwiriskirika nchito vilondezgekenge. Likusazgapo vinthu vinandi ivyo vikusangika mu C wakumanyikwa yayi, nga ni masamu ghakukhazikika, malo gha adiresi ghakuchemeka, na adiresi ya I/O hardware.

 Syntax 

C yina dango la kalembero yakuzomeleka yakukhazikika na Muyezo wa C. Contains a BNF grammar for C. Kumalizga kwa mizere kanandi nkhwakuzirwa yayi mu C; kweni, mphaka ya mzere yili na ng’anamuro pa nyengo ya preprocessing. Makomenti ghangawoneka pakati pa ma delimiters /* na */, panjiso (kwamba C99) kulondezga // m’paka kuumaliro wa mzere. makomenti ghakukhozgeka na /* na */ ghaku ŵazgika yayi ndipo ndondomeko iyi ya ma characters yikung’anamulika yayi nga ma delimiters pala yasangika mukati mwa ma string panjiso ma character literal.

Mafayilo gha C source ghali na vipharazgo na vilongosolero vya ntchito. Malongosolero gha ntchito, nayo, ghali na vipharazgo na mazgu . Vipharazgo vikulongosora mitundu yiphya mwakugwiliskira nchito mazgu ghakuzirwa nga ni struct, union, na enum, panji kugaŵira mitundu ku ndipo panji kusunga malo ghakusungirako vyakusintha viphya, kanandi pakulemba mtundu uwo ukulondezgeka na zina la vyakusintha. Mazgu ghakuzirwa nga ni charna intkulongosora mitundu yakupangika. Vigaŵa vya khodi vikuŵikika mu vingwe ( {ndipo }, nyengo zinyake vikuchemeka "vingwe vyakukhota") kuti vichepeske kukura kwa vipharazgo na kugwira ntchito nga ni mazgu ghamoza gha vigaŵa vyakulongozga.

Pakuŵa chiyowoyero chakukhumbikwa chomene, C wakugwiliskira ntchito mazgu kuti walongosore ivyo munthu wangachita. Mazgu agho ghakumanyikwa comene ni mazgu ghakuyowoya , agho ghali na mazgu agho ghakwenera kuyezgeka, ndipo ghakulondezgapo pakuŵa semicolon; nga ni chigaŵa cha kuwunika, milimo yingachemeka ndipo vyakusintha vikugaŵirika mitengo yiphya. Kuti musinthe umo mazgu ghakuchitikira mwakulondezganako, C wakupeleka mazgu ghanandi ghakulongozga-kulongozga agho ghakumanyikwa na mazgu ghakuzirwa ghakusungika. Mapulogalamu ghakupangika ghakovwirika na if... [ else] kuchitika kwakuzomerezgeka ndiposo na do... while, while, na forkuchitika mwakuwerezgawerezga (kuzungulira). Mazgu agha forghali na mazgu ghakupambanapambana ghakwamba, kuyezga, na kuyambiskaso, ghanyake panji ghose ghangalekeka. breakndipo continuelingagwiriskikiya nchitu mukati mwa lupu. Break yikugwiriskirika nchito kuti yifumemo mu mazgu ghakujalira mkati ndipo kulutilira yikugwiriskirika nchito kuti yijumphe ku kuyambiskaso kwake. Paliso gotomazgu ghambura kupangika agho ghakugaŵika mwaluŵiro ku chimanyikwiro chakusankhika mukati mwa ntchito. switchwakusankha a casekuti wakomeke mwakuyana na mtengo wa mazgu gha integer. Kupambana na viyowoyero vinyake vinandi, control-flow yizamuwira ku viyowoyero vinyake casekupatulapo para yamara na a break.

Mazgu ghangagwiliskira nchito mitundu yakupambanapambana ya vyakupangika ndipo ghangaŵa na mafoni ghakucemeka. Ndondomeko iyo mphindano za ntchito na operands ku ŵanandi awo ŵakugwira ntchito zikuwonekera zikumanyikwa yayi. Ma evaluation ghangaŵa kuti ghakunjilirapo. Kweni, vyose vyakukhwaskana na vyakuchitika (kusazgapo kusunga ku vyakusintha) vizamuchitika pambere " sequence point " yakulondezgapo yindakwane; fundo zakulondezgapo zikusazgapo umaliro wa mazgu ghakuyowoya ghaliyose, na kunjira na kuwelera kufuma ku foni ya ntchito yiliyose. Mfundo zakulondezganako zikuchitikaso pa nyengo ya kuwunika mazgu agho ghali na ŵanyake awo ŵakugwira ntchito ( &&, ||, ?:na awo ŵakugwira ntchito na koma ). Ici cikuzomerezga kuti ŵantu awo ŵakupanga mapulogiramu gha C ŵaŵikepo mtima comene kuti ŵasange vyakucitika vyakugomezgeka kuluska umo vikukhumbikwira ku viyowoyero vinyake vyakupangira mapulogiramu.

Kernighan na Ritchie ŵakuti mu Mazgu ghakwamba gha Chiyowoyero cha C : "C, nga ni chiyowoyero chilichose, chili na viheni vyake. Ŵanyake awo ŵakugwira ntchito ŵali na fundo zambura kwenelera; vigaŵa vinyake vya mazgu vingaŵa viwemi."  C standard yikayezga yayi kunozga vinandi vya viheni ivi, chifukwa cha umo kusintha kwanthena uku kukukhwaskira mapulogalamu agho ghalipo kale.

 Seti ya Character 
Malembo ghakwamba gha C source character set ni nthe malemba agha:
 Malembo gha Lowercase na uppercase gha ISO basic Latin alphabet: a–z, A–Z
 vipendo vya Decimal: 0–9
 vilemba vyakubeka (Graphic characters): ! " # % & ' ( ) * + , - . / : ; < = > ? [ \ ] ^ _ { | } ~
 malemba ghambula kubekeka (Whitespace characters): space, horizontal tab, vertical tab, form feed, newline

Chimanyikwiro cha mzere uphya chikulongora umaliro wa mzere wa malembo; likwenera yayi kuyana na lizgu limoza leneco, nangauli kuti liŵe lakunozga C wakuliwona nthena.

Malembo ghanyake ghakulembeka na ma byte ghanandi ghangaseŵezeskeka mu string literals , kweni ghakunyamulika yayi . Muyezo wasonosono wa C ( C11 ) ukuzomerezga kuti malembo gha Unicode gha vyaru vinandi ghaŵikike mwakunyamulika mukati mwa malembo gha C source mwa kugwiliskira nchito \uXXXXpanji \UXXXXXXXXkuŵika makodi (apo Xghakulongora chilembo cha hexadecimal), nangauli chinthu ichi chindagwiriskike nchito chomene.

Mazgu ghakwamba gha C ghakukomeka ghali na malembo ghakuyana waka, pamoza na vithuzithuzi vya chenjezgo , backspace , na kuwelera kwa galimoto . Wovwiri wa nyengo yakuchimbira wa malembo ghakusazgikira wasazgikira na kusintha kulikose kwa muyezo wa C.

 Mazgu ghakusungika 
Mazgu agho ghakulondezgapo ghakulembeka na vilembo vichokovichoko.

C89 ili na mazgu 32 ghakusungika, agho ghakumanyikwaso kuti ‘mazgu ghakuzirwa’, agho ghangagwiliskirika nchito yayi pa vinthu vinyake padera pa ivyo ghali kulongosoreka kale:

 auto
 break
 case
 char
 const
 continue
 default
 do
 double
 else
 enum
 extern
 float
 for
 goto
 if
 int
 long
 register
 return
 short
 signed
 sizeof
 static
 struct
 switch
 typedef
 union
 unsigned
 void
 volatile
 while

C89 ili na mazgu 32 ghakusungika, agho ghakumanyikwaso kuti ‘mazgu ghakuzirwa’, agho ghangagwiliskirika nchito yayi pa vinthu vinyake padera pa ivyo ghali kulongosoreka kale

 inline
 restrict
 _Bool ‡
 _Complex
 _Imaginary

C11 wakasazgapo mazgu ghanyake ghankhondi na ghaŵiri ghakusungika:  (‡ yikulongora zina linyake lakulembera lizgu lakuzirwa la C23)

 _Alignas ‡
 _Alignof ‡
 _Atomic
 _Generic
 _Noreturn
 _Static_assert ‡
 _Thread_local ‡

C23 wakasunga mazgu ghanyake khumi na ghankhondi:

 alignas
 alignof
 bool
 constexpr
 false
 nullptr
 static_assert
 thread_local
 true
 typeof
 typeof_unqual
 _BitInt
 _Decimal32
 _Decimal64
 _Decimal128

Mazgu ghanandi agho ghasungika sonosono apa ghakwamba na mzere wakulembeka pasi ndipo pamanyuma pake pali chilembo chikuru, chifukwa vimanyikwiro vya fomu iyo vikasungika kale na C standard kuti vigwiriskike nchito waka na kukhazikiska. Pakuti source code ya pulogiramu iyo yilipo yikwenera yayi kugwiliskira nchito vimanyikwiro ivi, yingakhwaskika yayi apo C implementations yikwamba kukhozgera vigaŵa ivi vya chiyowoyero cha pulogiramu. Mitu yinyake yakumanyikwa yikulongosora mazgu ghakuyana waka gha vimanyikwiro vyakulembeka pasi. Mazgu ghanyake ghakasazgikirapo nga ni mazgu ghakuzirwa na malembo ghawo ghakumanyikwa mu C23 ndipo macros ghakuyana waka ghakafumiskikapo.

Pambere C89, entrywakasungika nga ni lizgu lakuzirwa. Mu buku lawo lachiŵiri la The C Programming Language , ilo likulongosora ivyo vikamanyikwa kuti C89, Kernighan na Ritchie ŵakalemba kuti, "The ... [mazgu ghakuzirwa] entry, kale ghakasungika kweni ghakagwiriskirika nchito yayi, ghakusungikaso yayi." na " entryLizgu lakuzirwa lakubabika wakufwa likufumiskikapo."

 Ma Operators 

C supports a rich set of operators , iyo ni vimanyikwiro ivyo vikugwiriskirika nchito mukati mwa mazgu kuti vilongosore ivyo vikwenera kuchitika apo ŵakuwunika mazgu agha. C wali na Ma Operators agha:
 kupenda: +, -, *, /, %
 kuyaniska: =
 augmented assignment: 
 bitwise logic: ~, &, |, ^
 bitwise shifts: <<, >>
 Boolean logic: !, &&, ||
 conditional evaluation: ? :
 equality testing: ==, !=
 calling functions: ( )
 increment and decrement: ++, --
 member selection: ., ->
 object size: sizeof
 type: typeof, typeof_unqual since C23
 order relations: <, <=, >, >=
 reference and dereference: &, *, [ ]
 sequencing: ,
 subexpression grouping: ( )
 type conversion: (typename)

C wakugwiriskira ncito operator =(wakugwiriskira ncito mu masamu kurongora kuyana) kurongora mulimo, kulondezga ciyerezgero ca Fortran na PL/I , kweni mwakupambana na ALGOL na vyakufumapo vyake. C wakugwiriskira ncito opareshoni ==kuti wayezge usange ŵakuyana waka. Kufanana pakati pa awo ŵakugwira ntchito pa kugaŵira na kulinganiska kungapangiska kuti ŵagwiriskirenge ncito mwangozi yumoza mu malo gha munyake, ndipo nyengo zinandi kupuvya kukupangiska uthenga wakubudika yayi (nangauli ŵanyake awo ŵakuwunganya ŵakupanga chenjezgo). Mwaciyerezgero, mazgu ghakuti conditional if (a == b + 1)ghangalembeka mwambura kwenelera nga ni if (a = b + 1), agho ghazamupimika nga ni truekwambura kuti mtengo wa auli 0pamanyuma pa mulimo.

C operator pakwamba nyengo zose nchakupulikikwa yayi. Mwachiyelezgero, uyo wakugwira ntchito ==wakukaka chomene kuluska (wakuchitika pambere) awo ŵakugwira ntchito &(bitwise AND) na |(bitwise OR) mu mazgu nga ni x & 1 == 0, agho ghakwenera kulembeka nga ni (x & 1) == 0para ndivyo wakulemba code wakukhumba.

 "Hello, world" chiyelezgero 

Chiyelezgero cha "hello, world" icho chikawoneka mu buku lakwamba la K&R chazgoka chiyelezgero cha pulogiramu yakwamba mu mabuku ghanandi ghakusambizga vya pulogiramu. Pulogalamu iyi yikusindikizga "hello, world" ku mtundu wakumanyikwa , uwo kanandi ukuŵa pa terminal panji pa skrini.

Mtundu wakwamba ukaŵa wakuti:main()
{
    printf("hello, world\n");
}

Pulogalamu yakukolerana na ndondomeko ya "hello, world" ni:

#include <stdio.h>

int main(void)
{
    printf("hello, world\n");
}

Mzere wakwamba wa pulogiramu iyi uli na preprocessing directive, agho ghakulongoreka na #include. ci cikupangiska kuti wakulemba waŵikepo mzere wa khodi uwo na mazgu ghose gha mu stdio.h fayilo ya mutu, agho ghali na vimanyikwiro vya milimo ya kunjilirapo na kufumamo nga ni printf na scanf. The angle brackets surrounding stdio.h ghakulongora kuti fayilo ya mutu yingasangika mwakugwiliskira nchito nthowa yakupenjera iyo yikutemwa mitu iyo yikupelekeka na compiler ku mitu yinyake iyo yili na zina limoza (kupambana na makoti ghaŵiri agho kanandi ghakusazgapo mafayilo gha mutu gha ku malo panji gha pulojekiti).

Mzere wachiŵiri ukulongora kuti ntchito iyo yili na zina mainyikulongosoreka. Ntchito iyi mainyikugwira ntchito yapadera mu mapulogalamu gha C; malo gha nyengo yakuchitira vinthu ghakuchema mainntchito kuti yimbe kuchita pulogiramu. Mtundu wakulongosora intukulongora kuti mtengo uwo ukuwelera kwa wakuchema (mu nkhani iyi malo gha nyengo yakuchitira) chifukwa cha kuwunika mainntchito, ni nambala yakukwana. Lizgu lakuzirwa voidnga ni mndandanda wa parameter likulongora kuti mainntchito yikutora yayi mphindano.

Brace yakujulika yakukhotakhota yikulongora kwamba kwa khodi ilo likulongosora main function.

Mzere wakulondezgapo wa pulogiramu iyi ni mazgu agho ghakuchema (ndiko kuti, ghakupatuska kuchitika) ntchito yakuchemeka printf, iyo mu nkhani iyi yikupelekeka kufuma ku laibulale ya dongosolo . Mu kuyimbira uku, printfntchito yikujumpha (ndiko kuti yikuperekeka na) mphindano yimoza, iyo ni adiresi ya mtundu wakwamba mu chingwe cha literal "hello, world\n" . Chingwe cha literal ni ndondomeko yambura kumanyikwa iyo yikuŵikika yekha na wakulemba, na vinthu vya mtundu charna chimanyikwiro cha NULL chaumaliro (ASCII value 0) chikulongora umaliro wa ndondomeko (kuti yizomerezgeke printfkumanya utali wa chingwe). Chimanyikwiro cha NULL chingalembekaso nga ni ndondomeko ya kutchimbira \0 . The \nni ndondomeko ya kutchimbira iyo C yikung’anamura ku chimanyikwiro cha mzere uphya , icho, pa kufumamo, chikulongora umaliro wa mzere wa sono. Mtengo wakuwelera wa printfntchito ni wa mtundu int, kweni ukutayika mwakufwasa chifukwa ukugwiriskirika nchito yayi. (Pulogalamu yakupwelelera comene yingayezga mtengo wakuwelera kuti yiwone usange printfmulimo uwu wacita makora.) Semicolon ;yikumara mazgu.

Chingwe chakujalira cha curly chikulongora umaliro wa khodi ya mainntchito. Malinga na C99 specification na viphya, mainntchito (kupambana na ntchito yinyake) yizamuweleska mtengo wa 0para yafika pa }iyo yikumara ntchito.  Mtengo wakuwelera wa 0ukung’anamulika na ndondomeko ya nyengo yakuchitira nga ni khodi yakufumamo iyo yikulongora kuti ntchito yikuchitika makora.

 ma Data types 

thumb
type system ya C ni ya static ndipo yili weakly typed, iyo yikuyiyaniska na type system ya ŵazukulu ALGOL nthe Pascal.  Pali ma built-in types ya ma integer ya milingo yakupambana-pambana, ya signed na ya unsigned, ma nambala ya floating-point , na ma enumerated types (enum).  Mtundu wa integer charkanandi ukugwiriskirika nchito pa malembo gha byte yimoza. C99 wakasazgapo mtundu wa data ya Boolean . Paliso mitundu yakufumiramo kusazgapo ma arrays , pointers , marekodi ( struct), na ma union ( union).

C kanandi yikugwiriskirika nchito mu mapulogiramu gha ndondomeko zapasi apo kutchimbira kufuma ku ndondomeko ya mtundu kungaŵa kwakukhumbikwa. Munthu uyo ​​wakulemba mabuku wakuyezgayezga kuwoneseska kuti mazgu ghanandi ghakulembeka makora, kweni uyo wakulemba mapulogiramu wangasintha ivyo vikulembeka mu nthowa zakupambanapambana, panji wakugwiliskira ntchito mtundu wa cast kuti wasinthe mwakudunjika mtengo kufuma ku mtundu unyake kuya ku unyake, panji wakugwiliskira ntchito vimanyikwiro panji maunioni kuti wazgoreso vigaŵa ivyo vili pasi . ya chinthu cha data mu nthowa yinyake.

Ŵanyake ŵakuwona kuti C's declaration syntax njambura kupulikikwa, chomenechomene pa vimanyikwiro vya ntchito . (Maghanoghano gha Ritchie ghakaŵa ghakuti ŵapharazge vimanyikwiro mu vigaŵa ivyo vikuyana na kugwiliskira ntchito kwawo: " kupharazga kukulongora kugwiliskira ntchito ".)

Kusintha kwa masamu kwa C kwa nyengo zose kukuzomerezga kuti khodi yiwemi yipangike, kweni nyengo zinyake yingapangiska kuti paŵe vyakuchitika vyambura kulindilirika. Mwachiyelezgero, kuyezgelera manambara ghakukwana ghakusayinirika na ghambura kusayinirika ghakuyana waka kukukhumba kusintha mtengo wakusayinirika kuŵa wambura kusayinirika. Ici cingapangiska kuti paŵe vyakucitika vyambura kulindilirika usange mtengo uwo mwasayinira ngwambura kwenelera.

 ma Pointers 
C yikukhozgera kugwiliskira nchito vimanyikwiro , mtundu wa vimanyikwiro ivyo vikulemba adiresi panji malo gha chinthu panji ntchito mu kukumbukira. Ma pointer ghangafumiskikapo kuti ghasange data iyo yasungika pa adiresi iyo yikulongosoreka, panji kuti yicheme ntchito yakulongosoreka. Ma pointer ghangaseŵezeskeka mwakuseŵezeska ntchito panji masamu gha pointer . Kuyimilira kwa nyengo yakuchimbira kwa mtengo wa pointer kanandi ni adiresi ya memory yambura kupangika (panji yikuwonjezgeka na offset-within-word field), kweni pakuti mtundu wa pointer ukusazgapo mtundu wa chinthu icho chikulongoreka, mazgu ghakusazgapo pointer ghangawoneka na mtundu . pa nyengo yakuwunganya. Pointer arithmetic yikupimika yekha na kukula kwa mtundu wa data wakulongozgeka.

Vimanyikwiro vikugwiriskirika ncito pa vinthu vinandi mu C. Vingwe vya malemba vikusinthika comene mwakugwiliskira ncito vimanyikwiro mu vigaŵa vya malembo. Kugaŵika kwa kukumbukira kwa nkhongono kukuchitika mwakugwiliskira ntchito vimanyikwiro; chakufumapo cha a mallockanandi chikuponyeka ku mtundu wa data wa data iyo yikwenera kusungika. Mitundu yinandi ya data, nga ni makuni , yikugwiriskirika ncito comene nga ni structvinthu ivyo vikugaŵika mwa nkhongono ivyo vikukolerana pamoza mwakugwiliskira ncito vimanyikwiro. Vimanyikwiro vya vimanyikwiro vinyake kanandi vikugwiriskirika nchito mu magulu gha vigaŵa vinandi na magulu gha structvinthu. Vimanyikwiro vya milimo ( vimanyikwiro vya milimo ) ni vyakovwira pakujumpha milimo nga ni mphindano ku milimo ya pamwamba (nga ni qsort panji bsearch ), mu matebulo ghakutumizga , panji nga ni callbacks ku awo ŵakulongozga vyakuchitika . 

Muyezo wa null pointer ukulongora mwakudunjika kuti palije malo ghakwenelera. Kufumiskiramo mtengo wa null pointer kukulongosoreka yayi, kanandi kukupangiska kuti paŵe suzgo la kugaŵa . Null pointer values ​​ndizo zikovwira pakulongora milandu yapadera nga ni para palije "next" pointer mu node yaumaliro ya mndandanda wakukolerana , panji nga ni chilongolero cha kubudika kufuma ku milimo yakuwelera vimanyikwiro. Mu vigaŵa vyakwenelera mu source code, nga nkhupeleka ku pointer variable, null pointer constant yingalembeka nga ni 0, na panji kwambura kuponya mwakudumura ku mtundu wa pointer, nga ni NULLmacro iyo yikulongosoreka na mitu yinandi yakumanyikwa panji, kufuma apo C23 na constant . nullptr. Mu vigaŵa vyakukhazikika, vimanyikwiro vyambura kanthu vikuwoneka ku false, apo vimanyikwiro vinyake vyose vikuwoneka ku true.

Vimanyikwiro vyambura kanthu ( void *) vikulongora vinthu vya mtundu wambura kumanyikwa, ndipo ntheura vingagwiliskirika nchito nga ni vimanyikwiro vya data vya "generic". Pakuti kukura na mtundu wa chinthu icho chikulongosoreka vikumanyikwa yayi, vimanyikwiro vyambura kanthu vingafumiskikapo yayi, panji masamu ghakulongora pa iwo ghakuzomerezgeka yayi, nangauli vingaŵa vyambura kusuzga (ndipo mu vigaŵa vinandi vikusinthika) ku na kufuma ku chilongolero chinyake chilichose cha chinthu . mutundu. 

Kugwiriskira ncito vimanyikwiro mwambura kupwelelera kungaŵa kwakofya. Chifukwa chakuti kanandi ŵakuwonekera yayi, pointer variable yingapangika kuti yilongore malo ghaliyose ghambura kumanyikwa, agho ghangapangiska kuti paŵe vyakuchitika vyambura kukhumbikwa. Nangauli vimanyikwiro ivyo vikugwiriskirika ncito makora vikulongora malo ghakuvikilirika, vingapangika kuti vilongore malo ghambura kuvikilirika mwa kugwiliskira ncito masamu gha vimanyikwiro ghambura kugwira nchito ; vinthu ivyo ŵakulongora vingalutilira kugwiliskirika nchito para vyagaŵika ( dangling pointers ); vingagwiriskikiya nchitu kwambula kuti viŵikika pakwamba ( wild pointers ); panji ŵangapika mwaluŵiro mtengo wambura kuvikilirika mwakugwiliskira nchito cast, union, panji kwizira mu pointer yinyake yakuvunda. Mu vigaŵa vinandi, C wakuzomerezga kugwiliskira ntchito na kusintha pakati pa mitundu ya vimanyikwiro, nangauli ŵakuwunganya ŵakupeleka vyakusankha vyakuwonera vigaŵa vyakupambanapambana. Viyowoyero vinyake vyakupanga mapulogiramu vikumazga masuzgo agha mwa kugwiliskira nchito mitundu yakukanizga comene ya vimanyikwiro.

 ma Array 

Mitundu ya Array mu C ndiyo yikukhazikika, kukura kwakukhazikika uko kukulongosoreka pa nyengo yakuwunganya. Muyezo wa C99 wasonosono ukuzomerezgaso mtundu wa ma array gha utali wakusinthasintha. Kweniso, vingachitikaso kugaŵira chigaŵa cha kukumbukira (cha kukula kwake) pa nyengo yakuchitira, kugwiriskira ntchito mallocntchito ya layibulare yakumanyikwa, na kuyiwona nga ni ndondomeko.

Pakuti ma array nyengo zose ghakusangika (mu nchito) kwizira mu vimanyikwiro, ma array ghakusangika kanandi ghakuwonekera yayi pa kukula kwa array iyo yili pasi, nangauli ŵanyake awo ŵakuwunganya ŵangapeleka kuwonekera kwa mphaka nga ni chisankho.  Kuswa kwa mphaka ya Array ntheura nkhwamachitiko ndipo kungapangiska kuti paŵe masuzgo ghakupambanapambana, kusazgapo kufika pa memory kwambura kuzomerezgeka, kunanga data, buffer overruns , na kupatulapo nyengo yakuchitira.

C ilije ndondomeko yapadera yakupharazgira ma arrays gha vigaŵa vinandi , kweni m’malo mwake yikuthemba pa kuweleraso mukati mwa mtundu wa ndondomeko kuti yipharazge ma arrays gha ma arrays, agho ghakufiska makora chinthu chimoza. Index values ​​ya "mndandanda wa vigaŵa vinandi" yingaghanaghanirika kuti yikukura mu ndondomeko yikuru ya mzere . Ma array gha vigaŵa vinandi ghakugwiriskirika nchito comene mu ma algorithm gha manambara (comenecomene kufuma ku algebra ya mzere wakugwiriskirika ncito ) kusunga matrices. Kapangidwe ka C array kakuyana makora na mulimo uwu. Kweni, mu mitundu yakwamba ya C mphaka ya mndandanda yikwenera kumanyikwa na mtengo wakukhazikika panji kujumpha mwakudunjika ku ndondomeko yiliyose iyo yikukhumba, ndipo mndandanda wa mndandanda wakukhora ungasangika yayi mwakugwiliskira nchito indexing kaŵiri. (Nthowa yakumazgira ivi yikaŵa yakugaŵira mndandanda na "mzere vector" wakusazgikira wa vimanyikwiro ku mizati.) C99 wakayambiska "mndandanda wa utali wakusintha" uwo ukulongosora nkhani iyi.

Chiyelezgero chakulondezgapo chakugwiriskira ncito C ya mazuŵa ghano (C99 panji pamanyuma) cikulongora kugaŵika kwa mndandanda wa vigaŵa viŵiri pa mulu na kugwiriskira ncito mndandanda wa vigaŵa vinandi vyakuŵikapo vimanyikwiro vyakufikapo (ivyo vingagwiliskira ncito mphaka-kuwoneseska pa ŵanandi ŵa C compilers):int func(int N, int M)
{
  float (*p)[N] [M] = malloc(sizeof *p);
  if (p == 0)
    return -1;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++)
      (*p)[i] [j] = i + j;
  print_array(N, M, p);
  free(p);
  return 1;
}

Ndipo pano pali kukhazikiska kwakuyana waka pakugwiriskira ncito cigaŵa ca C99 ca Auto VLA: 
int func(int N, int M)
{
  // Caution: checks should be made to ensure N*M*sizeof(float) does NOT exceed limitations for auto VLAs and is within available size of stack.
  float p[N] [M]; // auto VLA is held on the stack, and sized when the function is invoked
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++)
      p[i] [j] = i + j;
  print_array(N, M, p);
  // no need to free(p) since it will disappear when the function exits, along with the rest of the stack frame
  return 1;
}

 Kusinthanika kwa Array–pointer 
Mazgu ghakulembeka pasi x[i](apo xghakulongora chimanyikwiro) ni shuga wa syntactic wa *(x+i).  Kugwiriskira ncito cimanyisko ca wakuwunganya ca mtundu wa pointer, adiresi iyo x + iyikulongora kuti ni adiresi yakwamba yayi (iyo yikulongora na x) iyo yikusazgikira na ima byte, kweni m’malo mwake yikulongosoreka kuti ni adiresi yakwamba iyo yikusazgikira na ikuchulukiskika na kukula kwa an . chinthu icho xchikulongora ku. Mwantheura, x[i]wakusankha i+1chigaŵa cha th cha ndondomeko.

Kweniso, mu vigaŵa vinandi vyakuyowoya (kupatulika kwakumanyikwa ni nga ni operand ya sizeof), mazgu gha mtundu wa array ghakusinthika mwaŵene kuŵa pointer ku chinthu chakwamba cha array. Ici cikung'anamura kuti ndondomeko yikukopeka yayi nga ni yose para yacemeka nga ni mphindano ku nchito, kweni m'malo mwake adiresi ya cigaŵa cake cakwamba pera ndiyo yikujumpha. Ntheura, nangauli mafoni ghakugwira ntchito mu C ghakugwiriskira ncito semantics yakujumpha-na-mtengo , ma array ghakujumpha na fundo .

Kukura kwa ndondomeko yose xkungamanyikwa mwa kugwiriskira ncito sizeofku mazgu gha mtundu wa ndondomeko. Kukura kwa chinthu kungamanyikwa pakugwiriskira ntchito opareshoni sizeofku chinthu chilichose chakufumiskikapo cha ndondomeko A, nga umo vikuŵira mu n = sizeof A[0]. Ntheura, chiŵelengero cha vinthu ivyo vili mu ndondomeko iyo yapharazgika Achingamanyikwa nga ni sizeof A / sizeof A[0]. Wonani kuti usange pali waka chimanyikwiro cha chinthu chakwamba nga umo vikuŵira kanandi mu C code chifukwa cha kusintha kwakujiyimira pakwekha uko kwalongosoreka pacanya apa, uthenga wakukhwaskana na mtundu wose wa ndondomeko na utali wake ukutayika.

 Kwendeska Memory 
Chimoza mwa vinthu vinyake vyakuzirwa chomene ivyo chiyowoyero cha pulogiramu chikuchita nkhupeleka malo ghakulongozgera memory na vinthu ivyo vikusungika mu memory. C wakupereka nthowa zitatu zikuru zakugaŵira kukumbukira vinthu:
 Static memory allocation: malo gha chinthu ghakuperekeka mu binary pa nyengo yakusonkheska; vinthu ivi vili na mlingo (panji umoyo) usange binary iyo yili navyo yikuŵikika mu kukumbukira.
 Automatic memory allocation: temporary objects can be stored on the stack, and this space is automatically freed and reusable after the block in which they are declared is exited.
 Dynamic memory allocation: mabuloko ghakukumbukira gha kukula kwake ghangapempheka pa nyengo yakuchitira vinthu mwakugwiliskira ntchito milimo ya layibulare nga ni mallockufuma ku chigaŵa cha kukumbukira icho chikuchemeka heap ; mabuloko agha ghakukhalilira mpaka apo ghazamufwatulika kuti ghagwiriskike nchitoso mwa kucema nchito ya layibulare reallocpanji free.

Nthowa zitatu izi ni zakwenelera mu nyengo zakupambanapambana ndipo zili na vyakuguliska vyakupambanapambana. Mwachiyelezgero, kugaŵira kwa kukumbukira kwakukhazikika kuli na mtengo uchoko wakugaŵira, kugaŵira kwakujiyimira paŵekha kungaŵa na mtengo ukuru pachoko, ndipo kugaŵira kwakukumbukira kwakusintha kungaŵa na mtengo ukuru wa kugaŵira na kugaŵira. Kukhalilira kwa vinthu vyambura kusintha nkhwakovwira kusunga uthenga wa boma pa mafoni ghakugwira ntchito, kugaŵira kwakujiyimira pakwekha nkhwambura kusuzga kugwiliskira nchito kweni malo ghakuŵikamo vinthu ghakuŵa ghachoko chomene ndiposo ghakukhala nyengo yichoko waka kuluska malo ghakukumbukira panji gha mulu, ndipo kugaŵira kwakukumbukira kwakukhozga kukuzomerezga kugaŵira vinthu ivyo kukula kwake kukumanyikwa waka pa nyengo yakuchitira. Mapulogalamu ghanandi gha C ghakugwiriskira ncito comene vyose vitatu.

Para nchamachitiko, kugaŵira kwakujiyimira pakwekha panji kwakukhazikika kanandi nkhwambura kusuzga comene cifukwa vyakusungirako vikulaŵilirika na uyo wakulemba, ndipo ivi vikufwatura uyo wakupanga pulogiramu ku mulimo uwo ungaŵa wakubudika wa kugaŵira na kufwatura vyakusungirako na mawoko. Kweni, vigaŵa vinandi vya data vingasinthika mu kukura pa nyengo yakuchitira, ndipo pakuti kugaŵira kwakukhazikika (na kugaŵira kwakujiyimira paŵekha pambere C99 yindafike) kukwenera kuŵa na kukula kwakukhazikika pa nyengo yakuwunganya, pali vinthu vinandi ivyo kugaŵira kwakukhozga kukukhumbikwa.  Pambere C99 standard, ma arrays ghakusinthasintha ghakaŵa chiyelezgero chakumanyikwa cha ichi. (Wonani nkhani yakukhwaskana na C dynamic memory allocation kuti muwone chiyelezgero cha ma arrays ghakugaŵika mwakusintha.) Mwakupambana na kugaŵika kwakujiyimira, uko kungatondeka pa nyengo yakuchitira vinthu na vyakuchitika vyambura kumanyikwa, ntchito zakugaŵika zakusintha zikuweleska chimanyikwiro (mu mtundu wa mtengo wa null pointer) apo . malo ghakusungirako ghakukhumbikwa ghangagaŵika yayi. (Static allocation iyo njikuru chomene kanandi yikumanyikwa na linker panji loader , pambere pulogiramu yindambe kugwira ntchito.)

Kupatulapo para vyalembeka vinyake, vinthu vyambura kusintha vikuŵa na zero panji null pointer values ​​para pulogiramu yayamba. Vinthu ivyo vikugaŵika mwaŵene ndiposo mwa nkhongono vikuyambiskika pekha usange mtengo wakwamba ukuyowoyeka mwakudunjika; apo yayi pakwamba ŵali na mtengo wambura kumanyikwa (kaŵirikaŵiri, chilichose icho chikuchitika kuti chiŵepo mu kusungirako , icho chingaŵa kuti chikwimira yayi mtengo wakuzomerezgeka wa mtundu uwo). Usange pulogiramu yikuyezga kusanga mtengo uwo undayambike, ivyo vikufumamo vikumanyikwa yayi. Ŵanthu ŵanandi awo ŵakuwunganya mabuku mazuŵa ghano ŵakuyezgayezga kumanya na kuchenjezga za suzgo ili, kweni vyose viŵiri, viwemi vyautesi na viheni vyautesi vingaŵapo.

Heap memory allocation yikwenera kukolerana na kugwiliskira ntchito kwake kwenikweni mu pulogiramu yiliyose kuti yigwiriskike nchitoso mwakukwana. Mwaciyelezgero, usange cilongolero cimoza pera ca kugaŵira kukumbukira kwa mulu cikufuma mu msinkhu panji mtengo wake ukulembeka pambere undagaŵike mwakudunjika, mbwenu kukumbukira uko kungasangikaso yayi kuti kugwiriskike ncitoso pamanyuma ndipo kukutayika comene ku pulogiramu, cinthu ico cikumanyikwa kuti kukumbukira . nthonya . Mwakupambana, nchamacitiko kuti kukumbukira kuŵe kwakufwatuka, kweni kukuyowoyeka pamanyuma, ndipo kukupangiska kuti paŵe vyakucitika vyambura kumanyikwa. Kanandi, vimanyikwiro vya kutondeka vikuwoneka mu cigaŵa ca pulogiramu ico cikukhwaskana yayi na khodi ilo likupangiska kuti paŵe suzgo, ndipo vikuŵa vyakusuzga kumanya usange vyatondeka. Nkhani zanthena izi zikunozga mu viyowoyero ivyo vikuwuskako viswaswa mwaŵene .

 Malaibulale 
Chiyowoyero cha C chikugwiriskira ncito malaibulale nga ni nthowa yake yikuru yakusazgirako. Mu C, laibulale ni gulu la milimo iyo yili mu fayilo yimoza ya "archive". Laibulale yiliyose kanandi yili na fayilo ya mutu , iyo yili na viyelezgero vya milimo iyo yili mukati mwa layibulare iyo yingagwiliskirika nchito na pulogiramu, na kupharazgira mitundu yapadera ya data na vimanyikwiro vya macro ivyo vikugwiriskirika nchito na milimo iyi. Kuti pulogiramu yigwiriskirenge nchito laibulale, yikwenera kuŵa na fayilo ya mutu wa laibulale, ndipo laibulale yikwenera kukolerana na pulogiramu, iyo mu nyengo zinandi yikukhumba mbendera za compiler (mwachiyelezgero, -lm, chifupi cha "kulumikiza laibulale ya masamu"). 

Laibulale ya C yakumanyikwa chomene ni C standard library , iyo yikulongosoreka na ISO na ANSI C standards ndipo yikwiza na kukhazikiska kuli kose kwa C (kukhazikiska uko kukukhwaska malo ghachoko waka nga ni ndondomeko zakuŵikika kungapereka waka chigaŵa chichoko wa laibulale yakumanyikwa). Laibulale iyi yikovwira pa ivyo vikunjilizgika na ivyo vikufumamo, kugaŵira kukumbukira, masamu, vingwe vya malembo, na nyengo. Mitu yinandi yakupambanapambana yakumanyikwa (mwaciyelezgero, stdio.h) yikulongosora umo vinthu ivi na vinyake vyakumanyikwa vya layibulare vikuŵikika.

Ntchito zinyake zakumanyikwa za C library ni izo zikugwiriskirika nchito na mapulogalamu agho ghakupangika na Unix na Unix-like systems, chomenechomene ntchito izo zikupereka mawonekero ku kernel . Ntchito izi zikulongosoreka mu vigaŵa vyakupambanapambana nga ni POSIX na Single UNIX Specification .

Pakuti mapulogiramu ghanandi ghalembeka mu C, pali malaibulale ghanyake ghakupambanapambana agho ghalipo. Malaibulale kanandi ghakulembeka mu C chifukwa C compilers ŵakupanga khodi ya vinthu yakunozga ; ŵakupanga mapulogalamu ŵakupanga ma interface gha layibulare mwakuti ndondomeko zingagwiliskirika nchito kufuma ku viyowoyero vyapachanya nga ni Java , Perl , na Python.

 File handling na streams 
Fayilo input and output (I / O) ni chigaŵa cha chiyowoyero cha C yayi kweni m'malo mwake chikuchitika na malaibulale (nga ni laibulale ya C standard) na mafayilo ghawo gha mutu wakukolerana (mwachiyelezgero stdio.h). Kugwiliskira ntchito mafayilo kukuchitika chomene kwizira mu I/O yapachanya iyo yikugwira ntchito kwizira mu milonga . Mtsinje ni kufuma pa fundo iyi data flow iyo yikujiyimira paŵekha na vipangizo, apo fayilo ni chipangizo cha simenti. I / O ya pamwamba yikuchitika kwizira mu kukolerana kwa mlonga na fayilo. Mu laibulale ya C standard, buffer (malo ghakukumbukira panji mzere) yikugwiriskirika nchito kwa kanyengo kuti yisungireko data pambere yindatumizgike ku malo ghakumalizgirapo. Ici cikucepeskako nyengo yakulindilira vipangizo ivyo vikucedwa, mwaciyelezgero, hard drive panji solid-state drive . Ntchito za I / O zapasi ni chigaŵa cha laibulale ya C yayi [ kulongosora kukukhumbikwa ] kweni kanandi zikuŵa chigaŵa cha mapulogalamu gha "bare metal" (mapulogalamu agho ghakujiyimira paŵekha na ndondomeko yiliyose yakugwiliskira ntchito nga ni mapulogalamu ghanandi ghakuŵikika ). Kupatulapo ŵachoko waka, kukhazikiska kukusazgapo I / O ya msinkhu wapansi.

 Vipangizo vya chiyowoyero 

A number of tools have been developed to help C programmers find and fix statements with undefined behavior or possibly erroneous expressions, with greater rigor than that provided by the compiler.  The tool lint was the first such, leading to many others.

Automated source code checking and auditing are beneficial in any language, and for C many such tools exist, such as Lint. A common practice is to use Lint to detect questionable code when a program is first written. Once a program passes Lint, it is then compiled using the C compiler. Also, many compilers can optionally warn about syntactically valid constructs that are likely to actually be errors. MISRA C is a proprietary set of guidelines to avoid such questionable code, developed for embedded systems.

There are also compilers, libraries, and operating system level mechanisms for performing actions that are not a standard part of C, such as bounds checking for arrays, detection of buffer overflow, serialization, dynamic memory tracking, and automatic garbage collection.

Tools such as Purify or Valgrind and linking with libraries containing special versions of the memory allocation functions can help uncover runtime errors in memory usage.

 magwiliskiro 

 Chifukwa chakugwiriskira ntchito mu mapulogalamu gha ndondomeko 
C yikugwiriskirika nchito comene pa kupanga mapulogiramu gha ndondomeko pakukhazikiska ndondomeko zakugwiliskira nchito na ndondomeko zakuŵikika .  Ichi nchifukwa cha vifukwa vinandi:
 Chiyowoyero cha C chikuzomerezga kuti vipangizo vya pa pulatifomu na kukumbukira viŵepo na vimanyikwiro na mtundu wa punning , ntheura vinthu vyakukhwaskana na ndondomeko (mwachiyelezgero, Control/Status Registers, I/O registers ) vingaŵikika na kugwiliskirika ntchito na khodi yakulembeka mu C – vikuzomerezga kuti vilongozgeke mwakukwana pa . pulatifomu iyo yikuchitikapo.
 Khodi ilo likupangika pamanyuma pa kuwunganya likukhumba yayi vinthu vinandi vya dongosolo , ndipo lingachemeka kufuma ku khodi yinyake ya boot mu nthowa yakunyoloka – nchakusuzga yayi kuchita.
 Mazgu gha chiyowoyero cha C na mazgu ghakuyowoyeka ghakuwoneka makora pa ndondomeko ya malango gha pulosesa yakukhumbikwa, ndipo chifukwa cha ichi pali nyengo yakuchimbira yichoko yakukhumbikwa pa vinthu vya mu dongosolo – vikuchitika mwaluŵiro ku . koma.
 Pakuti chiyowoyero cha C chili na ŵanthu ŵanandi awo ŵakugwira ntchito, chingagwiliskira ntchito vinthu vinandi ivyo vili mu ma CPU agho ghakukhumbikwa. Pa malo agho CPU yinyake yili na malango ghanandi ghakubisika, chiyowoyero chinyake chingapangika na panji intrinsic functions kuti chigwiriskirenge nchito malango agha – chingagwiliskira nchito pafupifupi vyose ivyo vikukhumbikwa na CPU.
 Chiyowoyero chikupangiska kuti chiŵe chipusu kuŵika vigaŵa pa vigaŵa vya data ya binary, kuzomerezga kuti data yipulikikwe, kulongozgeka na kusintha – yingalemba vigaŵa vya data, nanga ni mafayilo.
 Chiyowoyero ichi chikovwira ŵanthu ŵanandi awo ŵakugwira ntchito, kusazgapo kugwiliskira ntchito vinthu vichokovichoko, kuti ŵaŵe na masamu ghakukwana na maghanoghano, ndipo panji manambara ghakuyandama ghakukura mwakupambanapambana – chingagwiliskira ntchito makora data iyo yili kupangika makora.
 C ni chiyowoyero chichoko chomene, chili na mazgu ghachoko waka, ndipo chilije vinthu vinandi ivyo vikupanga khodi yikuru ya chilato – chikupulikikwa.
 C ili na mazaza ghakudunjika pa kugaŵira na kugaŵira vyakukumbukira, ivyo vikupereka nchito yiwemi na nyengo yakumanyikwa ku milimo ya kukumbukira, kwambura kufipa mtima na vyakuchitika vya nyengo na nyengo vyakusonkheska vyakuvunda - vili na ntchito yakumanyikwa .
 C yikuzomerezga kugwiliskira nchito na kukhazikiska ndondomeko zakupambanapambana za kugaŵira kukumbukira, kusazgapo  na ; nthowa yakunozga chomene na mabwalo; panji mtundu wa OS kernel uwo ungayana na DMA, kugwiliskira nchito mukati mwa kunjilirapo kwakutimbanizgas, panji kuphatikizgika na kukumbukira kwakuwoneka dongosolo.
 Kulingana na linker na malo, C code yingachemaso malaibulale agho ghalembeka mu chiyowoyero cha msonkhano, ndipo yingachemeka kufuma ku chiyowoyero cha msonkhano – yikukolerana makora na khodi yinyake ya pasi.
 C na calling conventions yake na linker structures vikugwiriskirika nchito chomene pamoza na viyowoyero vinyake vyapachanya, na kuchema kose ku C na kufuma ku C kukukhozgeka – vikukolerana makora na khodi yinyake yapachanya.
 C ili na chilengedwe chakukhwima chomene ndiposo chakukwana, kusazgapo malaibulale, mafuremu, ŵakuwunganya vyakujulika, ŵakunozga na vyakugwiriskira ntchito, ndipo ni de facto standard. Vikuwoneka kuti ŵakwendeska galimoto ŵalipo kale mu C, panji kuti pali CPU yakuyana waka nga ni back-end ya C compiler, ntheura pali kuchepeska chikhuŵilizgo cha kusankha chiyowoyero chinyake.

Kugwiriskira ncito mu malaibulale ghakugwiriskira ncito makompyuta ghanandi
C yikovwira awo ŵakupanga mapulogiramu kuti ŵapange ndondomeko yiwemi ya ma algorithm na data, chifukwa chigaŵa cha abstraction kufuma ku hardware nchakuwonda, ndipo mtengo wake ngwakuchepa, nthowa yakuzirwa chomene ya mapulogalamu ghakugwiriskira ntchito makompyuta. Mwaciyelezgero, Layibulare ya GNU ya Masamu Ghakukwana, Layibulare ya Sayansi ya GNU, Mathematica, na MATLAB vyose panji vigaŵa vinyake vikulembeka mu C. Viyowoyero vinandi vikukhozgera kucema milimo ya layibulare mu . C, mwachiyelezgero, Python-kukhazikika pa ndondomeko NumPy wakugwiriskira ncito C pa vigaŵa vyakugwira nchito comene na vyakukhwaskana na hardware.

C nga ni chiyowoyero cha pakati
C nyengo zinyake yikugwiriskirika nchito nga ni chiyowoyero cha pakati na kukhazikiska viyowoyero vinyake. Nthowa iyi yingagwiliskirika nchito kuti yiŵe yakunyamulika panji yakunozga; pakugwiriskira ncito C nga ni ciyowoyero ca pakati, vipangizo vinyake vyakupangika na makina vikukhumbikwa yayi. C ili na vinthu vinyake, nga ni malango gha mzere-nambala ya preprocessor na makoma ghambura kukhumbikwa ghakusankha ku umaliro wa mindandanda ya initializer, agho ghakovwira kuwunganya khodi iyo yapangika. Kweni vinyake ivyo C wakubudiska vyapangiska kuti paŵe viyowoyero vinyake viyowoyero vya C ivyo vikupangika mwakupambanapambana kuti vigwiriskike nchito nga ni viyowoyero vyapakati, nga ni C--. Kweniso, mabuku ghakuru gha mazuŵa ghano GCC na LLVM ghose ghali na kuyimilira kwapakati uko kuli C yayi, ndipo mabuku agha ghakovwira viyowoyero vinandi kusazgapo C.

 Viyowoyero vinyake ivyo vikulembeka mu C 
Chifukwa chakuti C yikusangika chomene ndiposo yikugwira ntchito makora, ntchakuti ŵakuwunganya mabuku , malaibulale na ŵakung’anamura viyowoyero vinyake vyakupanga mapulogiramu kanandi ŵakuvigwiriskira ntchito mu C.  Mwachiyelezgero, kukhazikiska kwa vimanyikwiro vya Python ,  Perl ,  Ruby ,  na PHP  vikulembeka mu C.

 Kamoza ŵakagwiliskiranga ntchito pakupanga webusayiti 
Mu mbiri, C nyengo zinyake wakagwiliskiranga ntchito pakupanga webusayiti mwakugwiliskira ntchito Common Gateway Interface (CGI) nga ni "chipata" cha uthenga pakati pa webusayiti, seva, na bulauza.  C yingaŵa kuti yikasankhika kuluska viyowoyero vyakung’anamulika chifukwa chakuti yikuchitika mwaluŵiro, yikukhazikika, ndiposo yikusangika pafupifupi pa charu chose.  Ntchinthu chakumanyikwaso yayi kuti kupanga mawebusaiti kuchitikenge mu C,  ndipo vinyake vinandi vyakupangira mawebusayiti vilipo.

 Ma seva gha pa webusayiti 
Ma seva ghaŵiri ghakumanyikwa chomene gha pa webusayiti , Apache HTTP Server na Nginx , ghose ghalembeka mu C. Ma seva agha ghakukolerana na ndondomeko yakugwiliskira ntchito, kutegherezga pa madowoko gha TCP ghakukhumba vya HTTP, ndipo pamanyuma ghakupereka vinthu vyambura kusintha pa webusayiti, panji kupangiska kuti vinyake vikomeke . viyowoyero vyakugwira ntchito kuti 'vipeleke' vinthu nga ni PHP , ivyo vikulembeka chomene mu C. Nthowa ya C yakupangira vinthu pafupi na chisulo yikupangiska kuti ŵazenge mapulogiramu agha ghakugwira ntchito makora chomene.

 ma applications gha End-user 
C nayo yagwiriskirika ncito comene pakukhazikiska mapulogiramu gha end-user. Kweni, mapulogalamu agha ghangalembekaso mu viyowoyero viphya, vyapachanya.

Ivyo C yingapanga cha

Nangauli C waŵa wakumanyikwa, wakukhwaska ndiposo wakupambana comene, kweni wali na viheni, kusazgapo:
 Muyezo wankhongono wakukumbukira ntchito na mallocndipo freendiwo wakubudika. Vipusikizgi ni ivi: Memory yikudontha para memory yagaŵirika kweni yikufwatulika yayi; na kufika pa memory iyo yikaŵa kuti yafwatulika kale
 The use of pointers and the direct manipulation of memory means corruption of memory is possible, perhaps due to programmer error, or insufficient checking of bad data.
 There is some type checking, but it does not apply to areas like variadic functions, and the type checking can be trivially or inadvertently circumvented.  It is weakly typed.
 Since the code generated by the compiler contains few checks itself, there is a burden on the programmer to consider all possible outcomes, to protect against buffer overruns, array bounds checking, stack overflows, memory exhaustion, and consider race conditions, thread isolation, etc.
 The use of pointers and the run-time manipulation of these means there may be two ways to access the same data (aliasing), which is not determinable at compile time.  This means that some optimisations that may be available to other languages are not possible in C.  FORTRAN is considered faster.
 Some of the standard library functions, e.g. scanf or , can lead to buffer overruns.
 There is limited standardisation in support for low-level variants in generated code, for example: different function calling conventions and ABI; different structure packing conventions; different byte ordering within larger integers (including endianness).  In many language implementations, some of these options may be handled with the preprocessor directive #pragma, and some with additional keywords e.g. use __cdecl calling convention.  But the directive and options are not consistently supported.
 String handling using the standard library is code-intensive, with explicit memory management required.
 The language does not directly support object orientation, introspection, run-time expression evaluation, generics, etc.
 There are few guards against inappropriate use of language features, which may lead to unmaintainable code.  In particular, the C preprocessor can hide troubling effects such as double evaluation and worse.  This facility for tricky code has been celebrated with competitions such as the International Obfuscated C Code Contest and the Underhanded C Contest.
 C lacks standard support for exception handling and only offers return codes for error checking. The  setjmp and longjmp standard library functions have been used to implement a try-catch mechanism via macros.

For some purposes, restricted styles of C have been adopted, e.g. MISRA C or CERT C, in an attempt to reduce the opportunity for bugs.  Databases such as CWE attempt to count the ways C etc. has vulnerabilities, along with recommendations for mitigation.

There are tools that can mitigate against some of the drawbacks.  Contemporary C compilers include checks which may generate warnings to help identify many potential bugs.

 Related languages 
alt=|thumb|The TIOBE index
graph, showing a comparison of the popularity of various programming languages

C has both directly and indirectly influenced many later languages such as C++ and Java. The most pervasive influence has been syntactical; all of the languages mentioned combine the statement and (more or less recognizably) expression syntax of C with type systems, data models or large-scale program structures that differ from those of C, sometimes radically.

Several C or near-C interpreters exist, including Ch and CINT, which can also be used for scripting.

When object-oriented programming languages became popular, C++ and Objective-C were two different extensions of C that provided object-oriented capabilities. Both languages were originally implemented as source-to-source compilers; source code was translated into C, and then compiled with a C compiler.

The C++ programming language (originally named "C with Classes") was devised by Bjarne Stroustrup as an approach to providing object-oriented functionality with a C-like syntax. C++ adds greater typing strength, scoping, and other tools useful in object-oriented programming, and permits generic programming via templates. Nearly a superset of C, C++ now supports most of C, with a few exceptions.

Objective-C was originally a very "thin" layer on top of C, and remains a strict superset of C that permits object-oriented programming using a hybrid dynamic/static typing paradigm. Objective-C derives its syntax from both C and Smalltalk: syntax that involves preprocessing, expressions, function declarations, and function calls is inherited from C, while the syntax for object-oriented features was originally taken from Smalltalk.

In addition to C++ and Objective-C, Ch, Cilk, and Unified Parallel C are nearly supersets of C.

 See also 

 Compatibility of C and C++
 Comparison of Pascal and C
 Comparison of programming languages
 International Obfuscated C Code Contest
 List of C-family programming languages
 List of C compilers

 Notes 

 References 

 Sources 

 By courtesy of the author, also at 



 Further reading 
  (source)
  (free)

  (archive)
  (archive)



  (free)

 External links 

 ISO C Working Group official website
 ISO/IEC 9899, publicly available official C documents, including the C99 Rationale

 comp.lang.c Frequently Asked Questions
 A History of C, by Dennis Ritchie
 C Library Reference and Examples


Category:American inventions
Category:Articles with example C code
Category:C programming language family
Category:Cross-platform software
Category:High-level programming languages
Category:Procedural programming languages
Category:Structured programming languages
Category:Programming languages created in 1972
Category:Programming languages with an ISO standard
Category:Statically typed programming languages
Category:Systems programming languages