Presentation is loading. Please wait.

Presentation is loading. Please wait.

C. C ? K & R C -- 1972 – The Kernighan and Richie classic ANCI C -- started 1983 – ANSI X3.159-1989 and ISO/IEC 9899:1990 – Standard C, C89, C90 C90 –

Similar presentations


Presentation on theme: "C. C ? K & R C -- 1972 – The Kernighan and Richie classic ANCI C -- started 1983 – ANSI X3.159-1989 and ISO/IEC 9899:1990 – Standard C, C89, C90 C90 –"— Presentation transcript:

1 C

2 C ? K & R C -- 1972 – The Kernighan and Richie classic ANCI C -- started 1983 – ANSI X3.159-1989 and ISO/IEC 9899:1990 – Standard C, C89, C90 C90 – Another ANSI standard (adds C++ features) GCC

3 C with objects C++ – Used for business and gaming applications Java – Used for networking and user interface – Executes on a “virtual machine” C# – Used by Microsoft

4 Why C? Programs can be fast Programs can be small Runs on many platforms – Including embedded processors – Generally with some version of GCC Relatively easy to learn Useful “standard” library

5 Why not C? Can get very obscure – ++a = *p->q + b * (x>y ? 5 : 13) ; Can lack robustness – Many viruses “attack” servers written in C Hard to manage large software projects – Without object-oriented techniques C++ can be fast Java can be small

6 C program -- 1 of 2 #include void countdown(int n) { int i ; for (i=n; i>= 1; --i) printf("%4d\n", i) ; puts("*** blastoff ***") ; }

7 C program -- 2 of 2 int main(int argc, char *argv[]) { int count ; puts("Enter start of count!") ; scanf("%d", &count) ; countdown(count) ; return 0 ; }

8 Running NCSU ECE 209 style $ nano example.c $ ls -l example* -rw-r--r-- 1 brock 501 278 Aug 17 17:48 example.c $ gcc -ansi -pedantic -Wall -Werror -o example example.c $ ls -l example* -rwxr-xr-x 1 brock 501 14796 Aug 17 17:48 example -rw-r--r-- 1 brock 501 278 Aug 17 17:48 example.c $./example

9 Looking at object code $ nano example.c $ gcc -ansi -pedantic -Wall -Werror -c example.c $ ls -l example* -rw-r--r-- 1 brock 501 278 Aug 17 17:48 example.c -rw-r--r-- 1 brock 501 936 Aug 17 17:58 example.o $ gcc -o example example.c

10 Looking at assembly code $ gcc -ansi -pedantic -Wall -Werror -S example.c From example.s i=n movl 8(%ebp), %eax movl %eax, -12(%ebp) --i followed by i>=1 leal -12(%ebp), %eax subl $1, (%eax) L2: cmpl $0, -12(%ebp) jg L3


Download ppt "C. C ? K & R C -- 1972 – The Kernighan and Richie classic ANCI C -- started 1983 – ANSI X3.159-1989 and ISO/IEC 9899:1990 – Standard C, C89, C90 C90 –"

Similar presentations


Ads by Google