Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit 10 Miscellaneous Advanced Topics Introduction to C Programming.

Similar presentations


Presentation on theme: "Unit 10 Miscellaneous Advanced Topics Introduction to C Programming."— Presentation transcript:

1 Unit 10 Miscellaneous Advanced Topics Introduction to C Programming

2 Unit 9 Review Unit 10: Review of Past Material

3 Unit 9 Review - Strings Strings are manipulated with the string library The string library is made available by including The strcpy() function copies from one string to another Concatenation (joining) of two strings uses the strcat() function The strlen() function returns the string length Versions of the string functions that contain the letter 'n' strncat() strncpy() strncmp() The sscanf() and sprintf() functions read and write strings

4 Unit 9 Review - Files You must first use a FILE * (file pointer) variable Use fopen() to access a file, and fclose() when done Using the "r" mode allows a file to be opened for reading Using the "w" mode empties/creates a file for writing Use fscanf() and fprintf() to read and write text files Use fread() and fwrite() to read and write binary files

5 Recursive Functions Unit 10: Miscellaneous Advanced Topics

6 Recursive Functions A problem which is defined in terms of a simpler version is suitable for a recursive solution For example, 2^n = 2 * 2^(n-1) A recursive function calls itself for a simpler version of the problem The base problem (n=0 or n=1) must be a known answer For example, 2^1 = 2

7 Structures Unit 10: Miscellaneous Advanced Topics

8 Structures A structure is an implementation of a database record A record is a collection of related information stored in fields Example: First-name, Last-name, Telephone-number C language syntax Keyword "struct" followed by brace Declare each field just like a variable declaration Closing brace Fields can be arrays or other structures Data is placed consecutively in memory, making a block

9 Unions Unit 10: Miscellaneous Advanced Topics

10 Unions Syntax is like a struct, except for keyword union The fields are mutually exclusive, only one applies at any time The memory for each field is overlaid in the same physical memory, all starting at the same location (beginning of union) Typically, a union appears as part of a larger struct record There is typically a sentinel variable which is used in the program to determine which is the applicable union member to use


Download ppt "Unit 10 Miscellaneous Advanced Topics Introduction to C Programming."

Similar presentations


Ads by Google