1 / 4

EEE305 Microcontroller Systems

Teaching resources on www.eej.ulst.ac.uk My office 5B18, telephone 028 90 366364 My email IJ.McCrum@ulster.ac.uk Lecture 2: Recap and intro to Strings. EEE305 Microcontroller Systems. Recap. #include < stdio.h > int main(void) { /* a simple program */ int i = 42;

talen
Download Presentation

EEE305 Microcontroller Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Teaching resources on www.eej.ulst.ac.uk My office 5B18, telephone 028 90 366364 My email IJ.McCrum@ulster.ac.uk Lecture 2: Recap and intro to Strings EEE305 Microcontroller Systems

  2. Recap #include <stdio.h> int main(void) { /* a simple program */ int i = 42; printf(“Hello %dth World!\n”,i); scanf(“%d”,&i); printf(“You entered %d\n”,i); return 0; }//--end of main--// First Program: note: role of each line! Functions: have a return type and are passed parameters – numbers to work on. Variables: Need to declare type to the compiler. Strings (and other constants 42, 42.0, ‘G’, “OK” Detail on printf – three types of things in the first parameter, text, format specifiersplaceholders % d and escape characters ‘\n’ Detail on scanf, passed a string specifying how to interpret typed in characters and pass the address of a variable where to put the converted text General points in C; how to comment, use of braces, sensible indenting (white space)

  3. Syntax in C – READ an ebook! Know how to declare variables - int, char, float and double Know how to declare and use arrays (using square brackets) e.g char me[80]; me[4]=‘I’; Know what a string is (an array of chars with a terminating value of ‘\0’ i.e 0x00Know Know the difference between the assignment operator = and the equality test = = Control structures and loops; If statements, single statement and compound statement forms.(L1_33 to L1_37) Switch…case statements (L1_39) While and Do loops (test at start or test at end) see L1_40 For loops L1_41 e.g for(i=0;i<10;i++){ //--do something 10 ten times --// } Functions; three things; declare them, use them and define them(give them a body) Preprocessor directives #include and #define in particular.

  4. First part of labwork: to be assessed! Week 4 NB hand in THURSDAY high noon, see website for dates Produce a decimal to hex table that looks like an improved version of the screenshot below. You solution should use loops and not have too many static strings (i.e use variables where possible). It should have extra labels, and look better.

More Related