Study your flashcards anywhere!

Download the official Cram app for free >

  • Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

How to study your flashcards.

Right/Left arrow keys: Navigate between flashcards.right arrow keyleft arrow key

Up/Down arrow keys: Flip the card between the front and back.down keyup key

H key: Show hint (3rd side).h key

A key: Read text to speech.a key

image

Play button

image

Play button

image

Progress

1/50

Click to flip

50 Cards in this Set

  • Front
  • Back
What is a block-structured language?
Means that things are enclosed inside braces, things are aware of things outside of their own braces, but not of things in braces that are not within their scope.
What is a program? What are the type of ``globals'' in a program?
functions, variables
What does the C Preprocessor do?
1) Trigraph Replacement - The preprocessor replaces trigraph sequences with the characters they represent.
2 Line Splicing - Physical source lines that are continued with escaped newline sequences are spliced to form logical lines.
3 Tokenization - The preprocessor breaks the result into preprocessing tokens and whitespace. It replaces comments with whitespace.
4 Macro Expansion and Directive Handling - Preprocessing directive lines, including file inclusion and conditional compilation, are executed. The preprocessor simultaneously expands macros and, in the 1999 version of the C standard, handles _Pragma operators
how do you do file inclusion?
#include <filename> searches the libraries for the file named.
#include "filename" is dependent, but ussually searches your current directory first, and then the library, for a file name.
What are the two macros?
#define name stuff - when this is compilled all things with name will be replaced with stuff. Any text can be substituted. You can also define things that look just like functions due to this.
#undef name - undefines the macro called name
conditional compilation:
#ifdef symbol - is this symbol defined?
#ifndef symbol - is this symbol defined?
#if constant-expression
statements
#endif
what are the integer types?
char - 1 byte
int <= short (short int) <=
long (long int)
(ussually, short 16,int 16, long 32)
floating:
float, double
specifies a floating point number of either single precision or double precision.
pointer to base_type
Pointers contain a location in memory rather than a actual value.Pointers point to a place rather than a thing, think address vs house.
compound:
arrays (type name[size];)- sequence of contiguous bytes in memory.
structs (struct tag {member-list} variable-list;) hold aggregate amounts of data
what are string's in C?
really just arrays of char terminated by a null character.
what is modifier register?
tells the compiler to (if it would) store the variable in register rather than in memory. This may cause faster execution, however, the compiler may ignore your request. Also, you cannot take the address of a register variable.
sizes of items (char vs. int, short vs. int, int vs. long, etc.)
char is always 1 byte, short must be at least 2, int must be >= short <= long, long must be 4.
What does static as a function modfier mean?
When used in front of a function declared outside of a block, it changes the linkage from external to internal. Now that function can only be accesed from within the source file they were declared in.
equivalence of pointers and arrays
Arrays are really just pointers that point to a location and when they are invoked, the pointer is dereferenced and the offset is added to the pointer.
What are the types of pointer arithmetic?
pointer +/- value - adds/subtracts the size of the data type of the pointer value times.
pointer - pointer - returns the number of sizeOf the pointer elements that are between the two pointers.
What are the types of loops in C?
for(expression1; expression2; expression3){}
AND
while( expression ) {}
AND
do{}while(expression);
What are the decision structures in C?
if(expression)
statement
else
statement
AND

switch (expression){
statementA:
break;
statementB:
statementC:
default: <= always if none match
}
What are the other non looping and non decision control structures in C?
goto label;
AND
fcn(params)
What does static as a variable modifier mean?
if outside a block, it is identical to the effects on a function with static, if within a block, it means the variable is now static instead of automatic, this means the variable exist from the time the program starts until the end of the program.
What does volatile mean as a modifier?
volatile informs the compiler that a value may be changed by outside forces. This stops the program from optimizing when it thinks a value cannot have changed.
What does const mean as a modifier?
constants are exactly like variables except their values cannot be changed.
int *pi; pointer to integer
int const *pci; pointer to constant integer
int * const pci; constant pointer to integer
int const * const pci; constant pointer to constant integer
What does unsigned mean as a type modifier?
unsigned means that it goes from 0 to 2^n power.
what does signed mean as a type modifier?
signed means it goes from -(2^n) power to (2^n) power.
What does short mean as a type modifier?
short means it is smaller or equal to int
What does long mean as a type modifier?
long means it is greater than or equal to int.
What is an expression?
anything that is followed by a ';' is an expression.
Unary operators?
Unary operators are operators that take only one value. such as ! ++ - & sizeOf
Binary Operators?
any operator that takes two values as arguments.
Prefix, Infix, Postfix Operators?
Operator appears before, In?, or after the operand.
using getc, getchar, fgetc.
getc( FILE *stream );//reads from the desired stream on character at a time
fgetc( FILE *stream );//same
getchar();//same but from standard input
declaring and calling functions
You will first make a prototype of the function before the function is actually declared, this makes the compiler aware of the function at that point. You call a function in a obvious way.
parameter passing, returning results
all parameters are passed in C pass-by-value, though the effects of this can be confusing at times. returns are also by value
Declaring pointers
type *name = &typeValue;
type casting
The (type) operator is called a cast and is used to explicitly convert the value of an expresssion to another type.
What are the 4 most common system calls.
open close read write
Call this system call when you leave a program for some reason.
exit();
difference between line and block buffering?
Line buffering usually delimits on the newline character, block buffering ussually stops when the buffer is full.
difference between FILE and file descriptor
FILE is a thing used to hold a stream to a currently open file.
using fopen and fclose
FILE *fopen(char const *name, char const *mode);
*mode can be "r","w","a","rb","wb", "ab"
If function fails NULL value returned.
fclose(FILE *f);
return != 0 if failed.
using putc, putchar, fputc
int putc( int character, FILE *stream); //puts character on stream
int fputc (int character, FILE *stream); //puts character on stream
int putchar( int character ); // puts character on standard output stream
using gets, fgets
char *fgets(char *buffer, int buffer_size, FILE *stream);//reads from buffer until buffer_size-1 is same or newline is encountered.NUL appended
char *gets(char *buffer);//same but on standard input
using puts, fputs
int fputs(char const *buffer, FILE *stream);//writes a nul terminated string to stream. Returns EOF if error occurs.
int puts(char const *buffer);// same but for stdout
using printf, fprintf, sprintf
int fprintf(FILE *stream, char const *format, ...);//prints acording to format
int printf( char const *format, ...);//same, but with stdout
int sprintf(char *buffer, char const *format, ...);//exact same as fprintf
using scanf, fscanf, sscanf
int fscanf(FILE *stream, char const *format, ...)//reads from stream until characters in the format could not be matched, number of conversions returned.
int scanf(char const *format, ...);//same but for standard input
int sscanf( char const *string, char const *format, ...);//exact same as fscanf
using strlen
size_t strlen(char const *string);

returns the number of characters the string contains.
//size_t is an unsigned integer
using strcpy, strncpy, strlcpy
char *strcpy( char *dst, char const *src);//copies src to dest, returns a pointer to dest array.
strncpy//same but only copies n characters, not null terminatued necesarily.
strlcpy//safer version of strcpy that knows the size
using strcat, strncat, strlcat
char *strcat( char *dst, char const *src);//appends src to dst, returns a pointer to destination array.
strncat//same, but does insert a nul at the end
strlcat//safeter version of strcat that knows the size
using strcmp, strncmp, strcasecmp, strncasecmp
int strcmp(char const *s1, char const *s2);
<0 if s1 less than s2, > 0 if s1 is greater than s2, = 0 if se == s2.
strncmp//same, but only compares first n characters
//ignores case
how do I access element in command-line argument handling: int main( int argc, char *argv[], char *env[] )
*argv gives first command line arguments
argc gives number of arguments first one is the name of the program though