IN3R11-2 -- C - Cours 1
41 pages
Catalan
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
41 pages
Catalan
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

IN3R11-2 { CCours 1Damien MASSONd.masson@esiee.frhttp://esiee.fr/ massond/Teaching/IN3R11-2/~19 novembre 2010Histoirebesoin d’un langage de haut niveau pour porter UNIXC parce qu’evolution de B (evolution de BCPL)1972, laboratoires Bell, Dennis Ritchie et Kenneth Thompson1989 : norme ANSI C (puis ISO C 90)1999 : norme ISO C 99, pas implantee par tous lescompilateurslangage imperatif a la fois haut et bas niveau2/40Les coupables3/40ReferencesB.W. Kernighan et D.M. Ritchie, Le langage Chttp://fr.wikibooks.org/wiki/Programmation_CLe cours sur lequel celui-ci est plagie :http://igm.univ-mlv.fr/ paumier/C~4/40C ou Java ?C Javaacces direct a la memoire completement portableencore tres utilise gestion automatique de lamemoirebeaucoup d’erreurs liees ala memoire extremement repandu,dans de plus en plus deprogrammation systemedomaines(Windows, UNIX, MacOS)oritente Objeton peut faire de l’objet,mais... puissants IDEdocumentation separee documentation generee et(man, web, mail au integree au codedeveloppeur...)Pour les performances, aujourd’hui, c’est pareil. (C plus rapide queJava pour certains programmes, l’inverse pour d’autres...). 5/40Chaine de compilationl’humain ecrit des chiers .cla compilation de ces chiers produit des chiers .ol’edition de liens entre ces chiers et des librairies produit unexecutable6/40Les chiers sources (.c) chiers textes en ASCIIcontiennent des instructions qui seront ...

Informations

Publié par
Nombre de lectures 47
Langue Catalan

Extrait

IN3R11-2 – C
Cours 1
Damien MASSON d.masson@esiee.fr
http://esiee.fr/~massond/Teaching/IN3R11-2/
19 novembre 2010
Histoire
besoin d’un langage de haut niveau pour porter UNIX
Cparceque´volutiondeB(´evolutiondeBCPL) 1972, laboratoires Bell, Dennis Ritchie et Kenneth Thompson 1989 : norme ANSI C (puis ISO C 90)
1999:normeISOC99,pasimplante´epartousles compilateurs
langageimpe´ratifa`lafoishautetbasniveau
/204
Les
coupables
3/40
R´efe´rences
B.W. Kernighan et D.M. Ritchie, Le langage C
http://fr.wikibooks.org/wiki/Programmation_C
Lecourssurlequelcelui-ciestplagi´e: http://igm.univ-mlv.fr/~paumier/C
4/40
C ou Java ?
C
acce`sdirect`alame´moire encoretresutilis´e ` beaucoup d’erreurs liees a ´ ` l´emoire a m programmationsyst`eme (Windows, UNIX, MacOS) on peut faire de l’objet, mais... documentationse´par´ee (man, web, mail au d´eveloppeur...)
Java l´etementportable comp gestion automatique de la me´moire extre`mementr´epandu, dans de plus en plus de domaines oritente´Objet puissants IDE documentationg´en´er´eeet int´egre´eaucode
Pour les performances, aujourd’hui, c’est pareil. (C plus rapide que Java pour certains programmes, l’inverse pour d’autres...).
/540
Chaine de compilation
lhumain´ecritdeschiers.c
lacompilationde ces fichiers produit des fichiers.o
l’nesediltion´edientre ces fichiers et deslibrairiesproduit executable ´
un
/640
Les
fichiers sources (.c)
fichiers textes en ASCII contiennent des instructions qui seront converties en code assembleur ces fichiers sont portables a condition de respecter la norme (pour ce cours ISO C 90) programmationmodulaire:unchierparth`eme
/704
deJava`aCetviceversa
Pareil.java
// i m p o r t j a v a . l a n g . S y s t e m ; c l a s s P a r e i l{ s t a t i c i n tc o m p a r e (d o u b l e[ ] t , d o u b l ee ){ i n t = ci ,1; f o r( i =0; i<3; i ++) i f( t [ i ]<e| |t [ i ]>e ) c =0; e l s ec =1; r e t u r nc ; }/c o m p a r e ( )/ p u b l i cs t a t i c v o i d ]main ( S t r i n g [ a r g v ){ d o u b l e = a b t[ ]{ 3 . 3 , 2 . 2 ,1 . 1}; i n tr=c o m p a r e ( t a b , 2 . 2 ) ; S y s t e m . o u t . p r i n t f (" r =% d \ n ", r ) ; // l a VM s ’ a r r e t e }/main ( )/ }/P a r e i l/
Pareil.c
#i n c l u d e< h .s t d i o> / e cp a s d l a s s e/ i n tc o m p a r e (d o u b l e ]t [ , d o u b l ee ){ i n t c =i ,1; f o r( i =0; i<3; i ++) i f( t [ i ]<e| |t [ i ]>e ) c =0; e l s ec =1; r e t u r nc ; }/c o m p a r e ( )/ i n tmain (i n ta r g c ,c h a ra r g v [ ] ){ d o u b l et a b [ ] ={ 3 . 3 , , 2 . 21 . 1}; i n t ; 2 . 2 ) ,r=c o m p a r e ( t a b p r i n t f (" r =% d \ n ", r ) ; r e t u r n0 ; }/main ( )/ /p a s d l a s s e e c/
0
Hello World
HelloWorld.c
/ . cH e l l o W o r l d  e s c l a s s i q u e d l a s s i q u e sLe c/
#i n c l u d e< h .s t d i o>
i n tmain (i n t ,a r g cc h a r ] ) [a r g v{ p r i n t f (" H e l l o  w o r l d !\ n ") ; r e t u r n0 ; }
/* commentaires */ include d’une librairie: inclusi on mainmegramdee´orpudtnrtneoi:p
9/40
Compilationetex´ecution
Compilation
>$ g c c H e l l o W o r l d . c >$ g c c H e l l o W o r l d . o
ou en un ´tape : e e
> . c e l l o W o r l d H$ g c c
E´ecution x
>$ . / H e l l o W o r l d H e l l o w o r l d !
c o
o
H e l l o W o r l d
H e l l o W o r l d
01/40
Un autre exemple prog.c
#i n c l u d e<s t d i o . h>
#d e f i n e 3P I . 1 4
f l o a ta , b ;
f l o a tsum (f l o a tx ,f l o a ty ){ r e t u r nx+y ; }
{
i n tmain (i n ta r g c ,c h a r ] )a r g v [ f l o a tc , d ; a=P I ; b =1; c=sum ( a , b ) ; p r i n t f (" % f  +  % f  =  % f \ n ", a , b , c ) ; p r i n t f (" d =% f \ n ", d ) ; r e t u r n0 ; }
> r o g . c$ g c c p r o go p
114/0
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents