Test 1A notes

Test 1A notes - g example: int grid[4][3]; fgets function...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
y locations (each storing a byte) numbered from 0 to 4x2 20 -1. If we execute the line - ch = 'A'; ed over 4 consecutive bytes, and the address of the variable storing the integer would be the first memory address the variable was stored in. ired information: n own as the effective size of the array. One would need to declare an extra integer variable to keep track of this. Since the name of an array is equivalent to a pointer to the beginning of an array g example: int grid[4][3]; tical. This helps explain exactly how arrays are passed in C. So what is the difference between a pointer and an array? While double values[10];allocates 10 locations to store doubles, double * ce expressions similar to the last one are used so often, there is a shorthand to access a field of a record through a pointer to that record. The last statement can also be written as: temp->salary = eed. If the new size is larger, the contents of the newly allocated portion of the object are unspecified. If size is 0 and ptr is not a null pointer, the object pointed to is freed. If the space cannot b fgets function Typically, in these sorts of files, some types of white space are delimiters for tokens (tabs and newlines, usually) and other white space (spaces) are not. The standard way to process these files is to read in one line at a time, and then use a "string tokenizer" to parse out the different pieces in a line. function that allows us to read in a whole line at once, fgets: char *fgets(char *restrict s , int n , FILE *restrict stream ); The first parameter represent the string into which you want to read in the line from the file. The second parameter represents the maximum number of characters you want to read in. (If the line is longer, n characters are
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

Test 1A notes - g example: int grid[4][3]; fgets function...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online