Aller au contenu

C (tutlayt)

Si Wikipedia, tasanayt tilellit.

La page Talɣa:Hlist/styles.css n’a pas de contenu.

C
Text in light blue serif capital letters on white background and very large light blue sans-serif letter C.
The C Programming Language[1] (often referred to as "K&R"), the seminal book on C
ParadigmImperative (procedural), structured
Designed byDennis Ritchie
DeveloperDennis Ritchie & Bell Labs (creators); ANSI X3J11 (ANSI C); ISO/IEC JTC1/SC22/WG14 (ISO C)
First appeared1972[2]
Stable release
C18 / yunyu 2018; 8 years ago (2018-06)
Typing disciplineStatic, weak, manifest, nominal
OSCross-platform
Filename extension.c, .h
Websitewww.open-std.org/jtc1/sc22/wg14/,%20https://www.iso.org/standard/82075.html,%20https://www.c-language.org/
Major implementations
K&R, GCC, Clang, Intel C, Microsoft Visual C++, Watcom C
Dialects
Cyclone, Unified Parallel C, Split-C, Cilk, C*
Influenced by
B (BCPL, CPL), ALGOL 68,[3] Assembly, PL/I, FORTRAN
Influenced
Numerous: AMPL, AWK, csh, C++, C--, C#, Objective-C, D, Go, Java, JavaScript, Julia, Limbo, LPC, Perl, PHP, Pike, Processing, Python, Ring,[4] Rust, Seed7, Vala, Verilog (HDL),[5] Nim

Tutlayt n usihel C d yiwet seg tutlayin n usihel i yesɛan azal ameqran deg umezruy n uselkim. Seg mi d-tlul deg useggas n 1972, teqqim d ttawil agejdan i usnulfu n inagrawen n wammud, isnasen, imikṛuselkimen, d waṭas n yisenfaren nniḍen.

C d tutlayt i d-yettaken afus i umessihel ad yeḥkem mliḥ deg wayen i d-yettxelliṣ neɣ iselḥu uselkim: takatut, asekkar, d tiddin n wahil. Deg yiwet n tama, C tqrib ɣer usekkar; deg tama nniḍen, tesɛa taseddast fessusen i yettɛawanen amdan ad yaru tangalt yettwafhamen.

Amezruy n C

[ẓreg | ẓreg aɣbalu]

Tutlayt C yesnulfu-tt-id Dennis Ritchie deg Bell Labs gar useggas n 1969 d 1973. Yella yesra tutlayt i yesɛan tazmert n usnulfu n unagraw Unix s wudem fessusen, arurad, yettwasnen.

Send C, llan tutlayin am B d BCPL, maca C tessaweḍ ad tili d ttawil ufrin, acku tella:

fessuset i uselmed,

teqreb ɣer usekkar,

tesɛa tiseddi deg usenker n wahil,

yettwasfsu s umsefsay,

tezmer ad tili ɣef waṭas n yiselkimen(tiɣeṛɣaṛt tanmidagt).

Deg useggas n 1978, Brian Kernighan d Dennis Ritchie ssuffɣen-d adlis d axatar: The C Programming Language. Adlis-a yuɣal d tamselɣut tagejdant i yimsihlen.

Sin akin, C tettwaslugen s wuṭṭunen n ilugan:

C89 / C90: alugen ANSI d ISO amezwaru.

C99: yerna-d ddeqs n tmerniyin am //, for (int i = 0; ...), d tawsatin nniḍen.

C11: yerna-d ttawilat i uselḥu amaynut d tɣellist.

C17: d aṣeggem n C11.

C23: d alugen atrar i d-yernan ddeqs n temsal timaynutin.

Tazwara: acu i d-yeǧǧan C ad tlul?

[ẓreg | ẓreg aɣbalu]

Deg taggara n iseggasen n 1960, deg Bell Labs (Merraw n Bell) di Marikan, llan imussnawen n tsenselkimt ttnadin ad snulfun anagraw n wammud amaynut, fessusen, yerna yettazzalen s tɣawla. Deg tallit-nni, Ken Thompson yella yettekki deg usenfar n Multics, maca asenfar-nni yuɣal d azuran, yerna yettwaḥseb d aẓayan i uselkim n tallit-nni.

Thompson yeǧǧa Multics, yebɣa ad yexdem anagraw amecṭuḥ, s unasiw amecṭuḥ, ɣef uselkim PDP-7. I wakken ad yessuffeɣ anagraw-a, yesnulfu-d tutlayt i wumi isemma B (seg 1969 ar 1970). B tella d tutlayt i d-yekkan seg BCPL (Basic Combined Programming Language), maca tesɛa tilas meqqren:

ur tesɛi ara tiwsatin n isefka, u txeddem kan s wawalen n tkatut n tiddi yiwet (mots), ur tezmir ara ad tessenker imuttiyen n tewsatin yemgaraden, arnu ur telli ara d tafessast i usenker n tkatut s wudem uslig.

Imiren, yella-d uselkim amaynut PDP-11, i yesɛan tiddi n tkatut n 8 n ibiten (octets). Tutlayt B ur telli ara tezmer ad tessenker anagraw ɣef uselkim-a. Dɣa dagi i d-yekka wugur i yessefken ad yettwafru s tutlayt tamaynut.

Dennis Ritchie d tlalit n C (1972)

[ẓreg | ẓreg aɣbalu]

Deg useggas n 1971–1972, Dennis Ritchie (i yettwassnen daɣen s yisem dmr) yedda-d ɣer Ken Thompson. Ritchie yebda yettbeddil tutlayt B:

yerna-d tiwsatin n isefka (int, char, float...), yerna-d timṣukin i wakken ad yessdukel isefka, yerra tutlayt tezmer ad tessenker tkatut s wudem i yiqerben ɣer usekkar, syin yefka-yas isem C, acku tella d tanernit n B (C d asekkil i d-iteddun deffir B).

Ihi, deg useggas n 1972, tlul-d tutlayt C. Ritchie yura amsefsay amezwaru n C ɣef uselkim PDP-11. Deg tallit-nni, C tella tettwaseqdec kan deg Bell Labs, gar imussnawen i yettxeddimen ɣef unagraw amaynut.

Unix yuɣal yettwaru s C (1973) — tagrawla tameqqrant

[ẓreg | ẓreg aɣbalu]

Deg useggas n 1973, Ken Thompson d Dennis Ritchie gezmen-tt di ṛṛay ad arun anagraw Unix s tutlayt C. Aya yella d tagrawla tameqqrant deg umezruy n uselkim, acku:

send 1973, inagrawen n wammud llan ttwarun s tutlayin n usuddes (assembly), i yiqerben mliḥ ɣer usekkar, maca ur zmiren ara ad ttwasnekren seg uselkim ɣer wayeḍ.

s C, Unix yuɣal s wudem n uzgay: nezmer ad t-nesselkem ɣef waṭas n yiselkimen yemgaraden, s ubeddel amecṭuḥ kan.

C tessken-d belli tutlayt n uswir ameqran tezmer ad tili d ttawil i usnulfu n unagraw n wammud s tɣawla, war ma nesṛuḥ asenker n tkatut.

Seg imiren, Unix d C uɣalen d tayuga yettwaqqnen. Yal taneqqiṭ n umezruy n C tezda d umenzu n Unix.

Asuffeɣ seg Bell Labs d udlis n K&R (1978)

[ẓreg | ẓreg aɣbalu]

Deg iseggasen n 1970, C tebda ad tazzal beṛṛa n Bell Labs:

imussnawen nniḍen bdan ttissinen-tt, snulfan-d imsefsayen nniḍen, C tebda tettwaseqdec deg isenfaren n iseɣẓanen d inagrawen.

Deg useggas n 1978, Brian Kernighan d Dennis Ritchie ssuffɣen-d adlis i yettwassnen aṭas: "The C Programming Language". Adlis-a yettwasemma s umata "K&R" (seg yismawen n yimura-s). Yuɣal d tamselɣut tagejdant i yimsihlen n umaḍal meṛṛa, yerna yefka-d "alugen" amezwaru n C, i yettwassnen ass-a s yisem "K&R C".

Deg tallit-a, llan aṭas n yimsefsayen n C i d-yeffɣen, maca yal yiwen yesɛa kra n umgired. Ayagi yessefk ad yettwafru s uslugen (tizeɣt).

Aslugen n C

[ẓreg | ẓreg aɣbalu]

Alugen amezwaru: ANSI C / C89 (1983–1989)

[ẓreg | ẓreg aɣbalu]

Deg useggas n 1983, ANSI (American National Standards Institute) tesbedd-d tamagrawt i wumi isemma X3J11, i wakken ad tessenker alugen n C. Sdeffir n 6 n yiseggasen n leqdic, deg useggas n 1989, ssuffɣen-d alugen amezwaru unṣib:

ANSI X3.159-1989, i yettwassnen s yisem "C89" neɣ "ANSI C".

Deg useggas n 1990, ISO teqbel alugen-a s ubeddel amecṭuḥ, tessuffeɣ-d ISO/IEC 9899:1990, i yettwassnen s yisem "C90". C89 d C90 qrib d yiwen. C89/C90 rnan-d ddeqs n tɣawsiwin i yessersen C ɣef llsas iḥersen:

  • tinaḍin n tesɣanin (prototypes de fonctions)
  • tamkarḍit talugant am stdio.h, stdlib.h, string.h
  • aslugen n uzarsekkar (préprocesseur)
  • aslugen n tewsatin d tseddast

Seg imiren, C tuɣal d tutlayt yettwassnen deg umaḍal meṛṛa, yettwasqedcen deg uselkim, deg usnas (deg uḥric temguri) d uselmed.

C99 (1999): anerni ameqqran

[ẓreg | ẓreg aɣbalu]

Sdeffir n mraw n yiseggasen, deg useggas n 1999, ISO tessuffeɣ-d alugen amaynut: ISO/IEC 9899:1999, i yettwassnen s yisem "C99". C99 yerna-d ddeqs n tmerniyin i yettɛawanen imessihlen:

  • iwenniten s // (am C++ d Java);
  • tawuriwin inline i arurad deg tidin n useɣwen;
  • isirawen(neɣ Tifelwiyin) n teɣzi yettbeddilen (tableaux à longueur variable, VLA);
  • tawsit _Bool (abulan) d stdbool.h;
  • tawsit long long i yemḍanen meqqren mliḥ;
  • stdint.h i tewsatin n tiddi yettwafren;
  • initialisation s yisem (designated initializers), am: struct point p = { .x = 1, .y = 2 };
  • tanaṭ "for" s ubeddu amaynut: for (int i = 0; i < n; i++).

C99 yettwaqbel s lemɣawla deg waṭas n yimsefsayen am GCC, maca kra n yimsefsayen nniḍen (am MSVC n Microsoft) ɣef llsas-nni ur t-ṭṭifen ara s timmad.

C11 (2011): C tuɣal ɣer tallit tatrant

[ẓreg | ẓreg aɣbalu]

Deg useggas n 2011, ISO tessuffeɣ-d ISO/IEC 9899:2011, i yettwassnen s yisem "C11" (neɣ C1X send ad d-yeffeɣ). C11 yerna-d ttawilat i yeqqnen ɣer uselkim atrar:

aselkem s waṭas n yiskaren (ugut n ikalan ifessasen) s threads.h;

timhalin tibelkamin s stdatomic.h, i yeqqnen ɣer uselkem yettwaqqnen;

_Generic i tefranin s tewsit;

timṣukin d tiddukliwin war isem (anonymous structs/unions);

static_assert i uselken deg wakud n usefsu;

yettwakkes gets() acku yella d aɣbalu n tuccḍiwin n tɣellist (tafuli n tkatut n weḥraz).

C11 tessken-d belli C tezmer ad teddu d tallit n uselkem s waṭas n yiskaren (iskaren yesɛan uget n wulawen) d tɣellist.

C17 / C18 (2018): aseggem kan

[ẓreg | ẓreg aɣbalu]

Deg useggas n 2018, ISO tessuffeɣ-d ISO/IEC 9899:2018, i yettwassnen s yisem "C17" neɣ "C18". Alugen-a ur yerni ara tamahilt tamaynut; yeṣeggam kan tuccḍiwin yellan deg C11, yerna yessufeɣ-d kra n usegzi. Ihi C17 yella d lqem n "aṣeggem", ur yelli ara d lqem n "tmerniyin".

C23 (2024): lqem atrar

[ẓreg | ẓreg aɣbalu]

Deg useggas n 2024, ISO tessuffeɣ-d alugen amaynut: ISO/IEC 9899:2024, i yettwassnen s yisem "C23" (neɣ C2X send ad d-yeffeɣ). C23 yerna-d ddeqs n tɣawsiwin i yebɣan imessihlen seg zik:

  • awalen yettwaṭṭfen bool, true, false (ur yesra ara ad nsekcem stdbool.h)
  • nullptr i usewwaṛ ilem (pointeur nul), s wudem iḥersen
  • auto i ubuddu n tewsit s wudem awurman
  • imḍanen s talɣa tamisint: 0b1010 (binaire)
  • isekkilen n uɣawas (attributes) s talɣa... [[...]]
  • typeof i wakken ad d-nawi tawsit n tengalt
  • #embed i wakken ad nsekcem ifuyla imisinen
  • yettwakkes ukayad n tewsatin (variable-length arrays) d kra n tɣawsiwin tiqburin.

C23 yesskan-d belli C mazal-itt tettbeddil, tettmerni, yerna tezmer ad teqqim d tutlayt tatrant.

Aseqdec n C ass-a

[ẓreg | ẓreg aɣbalu]

Ass-a, C mazal-itt d tutlayt yettwasqedcen aṭas, ladɣa deg yinagrawen ideg arurad d tkatut d lḥaǧa tagejdant:

Inagrawen n wammud: anagraw Linux yettwaru s C (akked kra n C++ d assembly); iferdisen n Windows d macOS daɣen.

Imikṛuselkimen d IoT: Arduino, STM32, ESP32, d yimikṛuselkimen n tkeṛṛusin, n tɣawsiwin, d tsenselkimt tadamsant.

Taffiwin n isefka: PostgreSQL, MySQL, SQLite ttwarun s C.

Imsefsayen: GCC, iferdisen n Clang/LLVM, d waṭas n yimsefsayen nniḍen.

Taɣellist tasenselkamt (cybersécurité): aṭas n yifecka n tɣellist ttwarun s C, acku zemren ad kecmen ɣer tkatut s wudem uslig.

Tigzi taragmawant: aṭas n temkarḍiyin n AI am TensorFlow d PyTorch sɛant llsas n C/C++ ddaw n Python.

Ayɣer C teqqim armi d ass-a?

[ẓreg | ẓreg aɣbalu]

Aṭas n tutlayin i d-yeffɣen seg 1972, maca C teqqim. Ayagi yella s kra n ssebbat:

Tussda d ururad: tangalt C tettwasfsu ɣer tengalt n usekkar s wudem i yeffɣen, war aselkem n waṭas n yiferdisen nnig-s.

Azgay: C tezmer ad tettwaseqdec ɣef qrib yal aselkim.

Asefrek n tkatut: C yettak-d afus i umessihel ad yesenker takatut s wudem uslig, ayen ilaqen deg yinagrawen d imikṛuselkimen.

Alugen iḥersen: seg C89 armi d C23, C tesɛa alugen yettwassnen, yettwaḥerzen.

Tamkarḍit d yimsefsayen: llan aṭas n yimsefsayen (GCC, Clang, MSVC...) d temkarḍiyin i C.

Taseddast fessusen: C ur tesɛi ara aṭas n wawalen yettwaṭṭfen, dɣa fessus i uselmed d usnulfu.

Taseddast n C

[ẓreg | ẓreg aɣbalu]

Taseddast n C d taseddast yesɛan ilugan iḥersen. Kra n yiferdisen agejdanen:

1. Tanaṭ

[ẓreg | ẓreg aɣbalu]

Yal tanaṭ deg C ttfaṛu s usekkil n unegzum: ;

Amedya:

int x = 5;

x = x + 1;

2. Iḥder n tinaḍin

[ẓreg | ẓreg aɣbalu]

Tinaḍin yettwagrunen deg yiwen n uḥder ttilint gar } d {.

Amedya:

if (x > 0)
{
    printf("x d ufrir\n");
}

3. Iwenniten

[ẓreg | ẓreg aɣbalu]

Deg C, nezmer ad naru iwenniten i wakken ad nsegzi tangalt.

/* Aya d awennit aɣezfan.
   Yezmer ad yili ɣef deqs n izirigen. */

// Aya d awennit ɣef izirig amaynut (seg C99).

4. Asekkil ameqran d umeẓyan

[ẓreg | ẓreg aɣbalu]

C yemgarrad gar isekkilen imeqqranen d imeẓyanen. Amedya:

int azal = 3;
int Azal = 5; // d amutti nniḍen

Deg C, azal d Azal mačči d yiwen.

Ahil amezwaru s C

[ẓreg | ẓreg aɣbalu]

Amedya amezwaru i yettwaɛerḍen deg yal tutlayt n usihel d “Azul, i umaḍal meṛṛa!”.

#include <stdio.h>

int main(void)
{
    printf("Azul, i umaḍal meṛṛa!\n");
    return 0;
}

Asegzi n wahil

#include <stdio.h>: tanaṭ n uzarsekkar i d-yewwin tasenṭeḍ stdio.h, yesɛan tisɣanin n unekcum d tuffɣa am printf.

int main(void): d tasɣent tagejdant. Deg C, ahil yettbeddu seg main.

printf(...): tasɣent i d-yessuffuɣen aḍris ɣer tuffɣa talugant.

\n: azamul i izirig amaynut.

return 0;: yemmal i unagraw belli ahil yemmed bla tuccḍa.

Ma nefsa-d tangalt-a s umsefsay, ad d-nawi afaylu yettwaselkemen. Mi ara neselkam-it, ad d-yeffeɣ:

Azul, i umaḍal meṛṛa!

Imuttiyen d tawsatin n isefka

[ẓreg | ẓreg aɣbalu]

Deg C, amutti d amkan i yettḥerzen azal. Yal amutti yesɛa isem d tawsit.

1. Tawsatin agejdanen

[ẓreg | ẓreg aɣbalu]
Tawsit C Anamek
int amḍan ummid
float amḍan s ticcert yettifliwen
double amḍan s ticcert yettifliwen s tneẓẓi meqqren
char asekkil
void ur yesɛi ara azal / ur d-yettara ara azal
_Bool abulan, seg C99

Amedya:

int amdan = 25;
float azal = 3.14;
double azal_d = 2.71828;
char asekkil = 'A';

2. Isem n umutti

[ẓreg | ẓreg aɣbalu]

Isem n umutti yezmer ad yesɛu:

isekkilen, izwilen, azamul _.

Maca ur yezmir ara:

ad yebdu s uzwil, neɣ ad yili d awal yettwaṭṭfen n C, neɣad yesɛu imeslayen ur nelli ara ASCII.

Amedya yelhan:

int age;
int user_name;
int total2;

3. Timezgiyin

[ẓreg | ẓreg aɣbalu]

Timezgiyin d azalen ur yettbeddilen ara. Deg C, nezmer ad nseqdec const neɣ #define.

const int aseggas = 2026;
#define PI 3.14159

Tisɣanin deg C

[ẓreg | ẓreg aɣbalu]

Tasɣent d aḥric n tangalt yixeddmen ccɣel neɣ tawuri yettwafrnen. Deg C, tasɣent tesɛa:

tawsit n tririt, isem, iɣewwaren ma llan, iḥder n tinaḍin.

1. Tisɣanin timeẓliwin

[ẓreg | ẓreg aɣbalu]

Amedya n tasɣent i yesnernayen sin imḍanen:

int smernu(int a, int b)
{
    return a + b;
}

Deg "main":

#include <stdio.h>

int smernu(int a, int b)
{
    return a + b;
}

int main(void)
{
    int ugmi = smernu(4, 6);
    printf("Ugmi = %d\n", ugmi);
    return 0;
}

Tuffɣa:

Ugmi = 10

2. Tasɣent ur d-yettaran ara azal

[ẓreg | ẓreg aɣbalu]

Ma yella tasɣent ur d-yettara ara azal, nseqdec "void".

void azul(void)
{
    printf("Azul!\n");
}

3. Tasɣent main

[ẓreg | ẓreg aɣbalu]

"main" d tasɣent tagejdant. Anagraw yettbeddu ahil seg-s. Yezmer ad tili s snat n talɣiwin:

int main(void)

neɣ:

int main(int argc, char *argv[])

Talɣa tis snat tettwasqdec mi ara nesɛa iɣewwaren seg izirig n unezḍay.

Asenqed n usuddem

[ẓreg | ẓreg aɣbalu]

Deg C, llan ttawilat i usenqed n tiddin n wahil: tiwtilin, allus, d tefranin.

1. if / else

[ẓreg | ẓreg aɣbalu]
if (azal > 0)
{
    printf("ufrir\n");
}
else if (azal < 0)
{
    printf("uzdir\n");
}
else
{
    printf("ilem\n");
}

2. switch

[ẓreg | ẓreg aɣbalu]
switch (ass)
{
    case 1:
        printf("Aram\n");
        break;
    case 2:
        printf("Aram s sin\n");
        break;
    default:
        printf("Ass nniḍen\n");
        break;
}

"for" yettwaseqdec aṭas i wallus yettwassnen.

for (int i = 0; i < 5; i++)
{
    printf("%d\n", i);
}

8.4. while

int i = 0;

while (i < 5)
{
    printf("%d\n", i);
    i++;
}

5. do while

[ẓreg | ẓreg aɣbalu]

"do while" yettwaxdem tikkelt tamezwaru send ad yessefqed tawtilt.

int i = 0;

do
{
    printf("%d\n", i);
    i++;
} while (i < 5);

6. break d continue

[ẓreg | ẓreg aɣbalu]

break: yessuffeɣ seg wallus neɣ seg switch.

continue: yettazzal ɣer tallut n wallus.

Isirawen d isewwaṛen

[ẓreg | ẓreg aɣbalu]

1. Isirawen

[ẓreg | ẓreg aɣbalu]

Isirew d agraw n imuttiyen n yiwen n tewsit. Deg C, isirew yettbeddu seg umatar 0.

int u[3] = {10, 20, 30};

printf("%d\n", u[0]); // 10
printf("%d\n", u[1]); // 20
printf("%d\n", u[2]); // 30

Ma yella nebɣa ad naru ɣef isirew: u[1] = 55;

u[1] = 55;

2. Azrar n isekkilen

[ẓreg | ẓreg aɣbalu]

C ur yesɛi ara tawsit tagejdant i uzrar n isekkilen am string deg tutlayin nniḍen. Azrar n isekkilen deg C d isirew n char yettfakku s usekkil '\0'.

char isem[] = "Kabylia";
printf("%s\n", isem);

3. Iswwaṛen

[ẓreg | ẓreg aɣbalu]

Asewwaṛ d amutti i yettḥerzen tansa n umutti nniḍen. Deg C, asewwaṛ yettwammel s *.

int x = 7;
int *p = &x;

Deg-s:

x d amutti yesɛan azal 7.

&x d tansa n x.

p d asewwaṛ i yesɛan tansa n x.

Ma nebɣa ad nbeddel azal s usewwaṛ:

*p = 10;

Tura x yuɣal 10.

Iswwaṛen d aferdis ameqran deg C. S ttawil-nsen nezmer ad nseqdec takatut s wudem afessas, maca daɣen zemren ad d-awin tuccḍiwin ma ur ttwaḥerzen ara mliḥ.

Timṣukin: struct, union, enum, typedef

[ẓreg | ẓreg aɣbalu]

1. struct

[ẓreg | ẓreg aɣbalu]

"struct" yettwaseqdec i usnulfu n tewsit yesɛan ddeqs n yiferdisen.

struct amdan
{
    int leɛmeṛ;
    char isem[20];
};

Aseqdec:

struct amdan a1;

a1.leɛmeṛ = 30;
a1.isem[0] = 'A';

2. typedef

[ẓreg | ẓreg aɣbalu]

"typedef" yettak isem amaynut i tewsit.

typedef struct amdan Amdan;

Amdan a2;
a2.leɛmeṛ = 25;

"enum" yettwaseqdec i wazalen yettwafernen.

enum ass { SED, ACER, ARIM, ARAM, AHAD, AMHAD, SEM };

"union" am "struct", maca iferdisen-is ttwaḥerzen deg yiwen n umkan n tkatut. Yernu mačči akk iferdisen zemren ad ḥerzen azal deg yiwen n wakud.

union azal
{
    int i;
    float f;
};

Asefrek n tkatut

[ẓreg | ẓreg aɣbalu]

Deg C, amessihel yesɛa afus ɣef tkatut. Aya d tazmert meqqren, maca daɣen d tamasit meqqren.

11.1. Aḥeṛṛi udmis

[ẓreg | ẓreg aɣbalu]

Ma nura:

int x;
int u[10];

takatut tettwaḥeṛṛi s wudem udmis, yerna teqqen ɣer umkan n wahil.

2. Aḥeṛṛi asmussaw

[ẓreg | ẓreg aɣbalu]

Aḥeṛṛi asmussaw yettwaxdem s malloc, calloc, realloc, seg stdlib.h.

Amedya:

#include <stdlib.h>

int *p = malloc(5 * sizeof(int));

if (p != NULL)
{
    p[0] = 1;
    p[1] = 2;
}

free(p);
  • malloc: yettḥeṛṛi takatut.
  • calloc: yettḥeṛṛi takatut s uwennez ɣer 0.
  • realloc: yettbeddel tiddi n tkatut yettwaḥerṛen.
  • free: yesenser takatut.

3. Tuccḍiwin n tkatut

[ẓreg | ẓreg aɣbalu]

Kra n tuccḍiwin yettwassnen:

  • ad yettwaseqdec usewwaṛ send ad yettwaḥeṛṛi,
  • ad yettwaseqdec usewwaṛ seld asenser-is,
  • ad yettwasenser umutti snat n tikkal,
  • ad yettwakes ɣer beṛṛa n isirew,
  • ad yettwattu "free".

Tuccḍiwin-a zemrent ad d-awint:

  • aḥbas n wahil,
  • azal ur yelhin ara,
  • tifuli n tkatut n weḥraz,
  • uguren n tɣellist.

Asettengel, asefsu, d uselkem

[ẓreg | ẓreg aɣbalu]

Tangalt C ur tettwaselkam ara srid. Tettɛeddi ɣef deqs n yisurifen.

1. Tangalt taɣbalut

[ẓreg | ẓreg aɣbalu]

Amessihel yettaru tangalt deg ufaylu s usiɣzef .c.

Amedya: ahil.c

2. Azarsekkar

[ẓreg | ẓreg aɣbalu]

Azarsekkar yettɛeddi qbel asefsu. Yettxeddem tinaḍin am:

#include <stdio.h>
#define PI 3.14159

3. Asefsu

[ẓreg | ẓreg aɣbalu]

Asefsay yessefsu tangalt C ɣer tengalt n usekkar neɣ ɣer iferdisen yettwaselkemen.

Amedya s GCC:

gcc ahil.c -o ahil

Deg unezḍay-a:

  • gcc: asefsay.
  • ahil.c: afaylu n tangalt taɣbalut.
  • -o ahil: isem n ufaylu n tuffɣa yettwaselkmen.

4. Amarraz

[ẓreg | ẓreg aɣbalu]

Amarraz yesdukel iferdisen yettwaselkemen d temkarḍiyin, i wakken ad d-yawi afaylu yettwaselkemen.

5. Aselkem

[ẓreg | ẓreg aɣbalu]

Mi ara neselkam afaylu:

./ahil

ahil iteddu.

Tamkarḍit talugant n C

[ẓreg | ẓreg aɣbalu]

C yesɛa tamkarḍit talugant i yettɛawanen imessihlen. Deg-s llan tisɣanin i tɣawsiwin yettwassnen.

1. stdio.h

[ẓreg | ẓreg aɣbalu]

Yesɛa tisɣanin n unekcum d tuffɣa.

  • printf: tuffɣa.
  • scanf: anekcum.
  • fopen, fclose: ifuyla.

Amedya n "scanf":

int x;
printf("Sekcem amḍan: ");
scanf("%d", &x);
printf("Teskecmeḍ: %d\n", x);

2. stdlib.h

[ẓreg | ẓreg aɣbalu]

Yesɛa tisɣanin n tkatut d tnaḍin nniḍen.

  • malloc
  • free
  • calloc
  • realloc
  • exit
  • atoi

3. string.h

[ẓreg | ẓreg aɣbalu]

Yesɛa tisɣanin i uzrar n isekkilen.

  • strlen
  • strcpy
  • strcat
  • strcmp

4. math.h

[ẓreg | ẓreg aɣbalu]

Yesɛa tisɣanin n tusnakt.

  • sqrt
  • pow
  • sin
  • cos
  • fabs

Amedya:

#include <math.h>
#include <stdio.h>

int main(void)
{
    double a = sqrt(16.0);
    printf("%f\n", a);
    return 0;
}

5. stdbool.h

[ẓreg | ẓreg aɣbalu]

Seg C99, yettak bool, true, false.

#include <stdbool.h>

bool yelha = true;

Tamselyut

[ẓreg | ẓreg aɣbalu]

Tiwelhiwin

[ẓreg | ẓreg aɣbalu]
  1. Kernighan, Brian W.; Ritchie, Dennis M. (February 1978). The C Programming Language (1st ed.). Englewood Cliffs, NJ: Prentice Hall. ISBN 978-0-13-110163-0.
  2. (Ritchie 1993): "Thompson had made a brief attempt to produce a system coded in an early version of C—before structures—in 1972, but gave up the effort."
  3. (Ritchie 1993): "The scheme of type composition adopted by C owes considerable debt to Algol 68, although it did not, perhaps, emerge in a form that Algol's adherents would approve of."
  4. Ring Team (5 December 2017). "Ring language and other languages". ring-lang.net. ring-lang. Archived from the original on 25 December 2018. Retrieved 20 April 2019.
  5. "Verilog HDL (and C)" (PDF). The Research School of Computer Science at the Australian National University. 2010-06-03. Archived from the original (PDF) on 2013-11-06. Retrieved 2013-08-19. 1980s: ; Verilog first introduced ; Verilog inspired by the C programming language Unknown parameter |deadurl= ignored (help)