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
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
Recursive Functions Unit 10: Miscellaneous Advanced Topics
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
Structures Unit 10: Miscellaneous Advanced Topics
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
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
Your consent to our cookies if you continue to use this website.