Difference: Lecture3:IntroductionToCProgramming (1 vs. 2)

Revision 22017-09-07 - uli

Line: 1 to 1
 
META TOPICPARENT name="LectureSlides"
Changed:
<
<
Start Presentation %SLIDESHOWSTART
>
>
Start Presentation

 

A bit of C programming

Lecture 3

Uli Raich

Line: 24 to 24
  or
Changed:
<
<
#include “myOwnIncludeFile.h”

>
>
#include “myOwnIncludeFile.h”

The C main program

As a first example people usually write the

“Hello World” program

#include <stdio.h>

void main() {

printf(“Hello World!\n”);

}


Let us try to compile and execute this program

First we start the editor, we type and save the program,

then we compile it using the gcc compiler and finally we execute it.

C data types

  • C has a number of data types:
  • char, short, int, long, float, double
  • unsigned char, unsigned short, unsigned int
  • can be extended to boolean (in C99 you can #include <stdbool.h>
  • No strings! But a pointer to a zero terminated chain of characters
  • struct
  • union
  • enum
And you can define your own data types with typedef

Assignements

We modify the program to do some calculation:

  %SLIDESHOWEND%

Revision 12017-09-07 - uli

Line: 1 to 1
Added:
>
>
Start Presentation
META TOPICPARENT name="LectureSlides"
%SLIDESHOWSTART

Slide 1: A bit of C programming

Lecture 3

Uli Raich

Slide 2: Programming Languages

To make a language a programming language it needs to implement:

  • Assignments
  • Conditional statements
  • loops

Slide 3: C libraries

C uses a large number of code libraries and you can create C libraries yourself.

These libraries may use special data types, which are defined in include files

Before using the library functions

#include <stdio.h>

or

#include “myOwnIncludeFile.h”

-- Uli Raich - 2017-09-07

Comments

<--/commentPlugin-->

META FILEATTACHMENT attachment="include.png" attr="" comment="" date="1504775835" name="include.png" path="include.png" size="5106" user="uli" version="1"
META FILEATTACHMENT attachment="include-1.png" attr="" comment="" date="1504775835" name="include-1.png" path="include-1.png" size="5319" user="uli" version="1"
META FILEATTACHMENT attachment="question.png" attr="" comment="" date="1504775835" name="question.png" path="question.png" size="16957" user="uli" version="1"
META FILEATTACHMENT attachment="structs.png" attr="" comment="" date="1504775835" name="structs.png" path="structs.png" size="30043" user="uli" version="1"
META FILEATTACHMENT attachment="switch-1.png" attr="" comment="" date="1504775835" name="switch-1.png" path="switch-1.png" size="23707" user="uli" version="1"
META FILEATTACHMENT attachment="switch-2.png" attr="" comment="" date="1504775835" name="switch-2.png" path="switch-2.png" size="34389" user="uli" version="1"
META FILEATTACHMENT attachment="questionRes.png" attr="" comment="" date="1504775904" name="questionRes.png" path="questionRes.png" size="8264" user="uli" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback