COP 3223C FINAL EXAM

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

#include

-#include <stdio.h> -inserts a particular header from another file - tell the CPP to get stdio.h from the system libraries and add the text to the current source file

a access mode

-opens a text file for writing in appending mode -if one doesn't exist, it will create a new one -program will start appending content in the existing file content

fgetc()

-reads a character from the input file referenced to by fp -returns the character read if success, EOF if error

fgets()

-reads up to n-1 characters from the input stream referenced to by fp -copies the read string into the buffer (buf), appending the null character to terminate the string

#

-stringsize operator -used within macro definition, converting a parameter into a string constant

all CPP begin with

# symbol -must be the first non blank character and for readability, a CPP directive should begin in the first column

#define

#define MAX_ARRAY_LENGTH 20 -substitutes a PP macro -tells the CPP to replace instances of MAX_ARRAY_LENGTH with 20 -use for constants to improve readability

#elif

#else and #if in one statement

#ifdef

#ifdef DEBUG -returns true if the macro is defined

#ifndef

#ifndef MESSAGE -returns true if the macro is not defined

#undef

#undef FILE_SIZE -undefines a PP macro

whats the difference between enum and macro

- follow scope rules - variables are automatically assigned values

parameters for fseek()

-1st: stream is the pointer to the file- -2nd: position of the record to be found -3rd: specifies the location where the offset starts

fwrite takes 4 arguments

-address of data to be written in disk -size of data to be written in disk -number of such type of data -pointer to the file where you want to write

errno

-global variable -indicated an error occurred during any function call

\

-macro continuation operator -continues a macro onto another line

C preprocessor

-not a part of the compiler, but a separate step in the compilation process -just a text substitution tool

a+ access mode

-opens a file for both reading and writing -creates a file if it does not exist -reading will start from the beginning but writing can only be appended

w+ access mode

-opens a text file for both reading and writing -first truncates the file to 0 length if it exists, otherwise creates a file if it does not exist.

w access mode

-opens a text file for writing -if one doesn't exist it will create a new one

how many access mode values are there?

6

#endif

ends preprocessor conditional

2 types of conversions

explicit (cast operator) and implicit (automatically done by compiler)

usual arithmetic conversions

first- integer promotion, if operands are still different types, then converted to type that appears highest in hierarchy

fread prototype

fread( address_data, size_data, numbers_data, pointer_to_file);

getting data using fseek()

fseek(FILE * stream, long int offset, int whence) -seeks the cursor to the given record in file

fwrite prototype

fwrite( address_data, size_data, numbers_data, pointer_to_file);

fclose() prototype

int fclose( FILE *fp );

simplest function to read a single character from a file

int fgetc( FILE * fp);

alternative for writing a string into a file

int fprintf(FILE *fp, const char *format, ....);

simplest function to write individual characters to a file

int fputc (int c, FILE *fp);

writing a null terminated string to a steream

int fputs( const char *s, FILE *fp);

reading a string from a file, but stopping after encountering the first space character)

int fscanf(FILE *fp, const char *format, ...)

parameterized macros

int square( int x) { return x*x; } can be rewritten as #define square(x) ((x) * (x))

#error

prints error message on stderr

integer promotion

process of converting values of int type 'smaller' than int or unsigned int are converted to int or unsigned int

__DATE__

returns the current date as a character literal in "MMM DD YYY" format

__TIME__

returns the current time as a character literal in "HH:MM:SS" format

access modes for opening binary files

same as the access modes for text files but with an added 'b' rb wb ab ...

What does a file represent?

sequence of bytes (regardless of it being a text file or a binary file)

##

-token pasting operator -within a macro definition combines 2 arguments

the defined() operator

-used in constant expressions to determine if an identifier is defined using #define -if defined: true: non-0 -if not defined: false: 0

fputc()

-writes the character value of the argument c to the output stream referenced by fp -returns the written character written on success, otherwise EOF if error

fputs()

-writes the string s to the output stream referenced to by fp -returns non negative value on success otherwise EOF if error

if we do not explicitly assign values to enum names, then the compiler assigned values starting from what number

0

fopen prototype

FILE *fopen( const char * filename, const char *mode);

C Programming provides access to what?

High and low (OS) level functions to handle file on storage devices.

EOF

a constant defined in the header file of stdio.h

usual arithmetic conversions are not performed for

assignment operators not logical operators && and ||

convert values from one type to another explicitly using

cast operator -(typename) expression

reading a string from a stream

char *fgets( char *buf, int n, FILE *fp);

fclose()

closing a file -returns 0 upon success or EOF if there is an error in closing -flushes any data still pending in the buffer, closes the file, then releases memory used for the file

__FILE__

contains the current file name as a string literal

__LINE__

contains the current line number as a decimal constant

type casting

converting a variable from one data type to another type

fopen()

create (and initialize) a new file or open an existing file

__STDC__

defined as 1 when the compiler compiles with the ANSI standard

perror()

displays the string you pass to it, followed by a colon, a space, and then the textual representation

#pragma

issues special command to the compiler using a standardized method

if fgets() encounters a new line character or EOF before reading the max number of characters

it returns only the characters read up to that point including the new line character

r+ access mode

opens a text file for both reading and writing

r access mode

opens an existing text file for reading purposes only

SEEK_SET whence in fseek()

starts the offset from the beginning of the file

SEEK_CUR whence in fseek()

starts the offset from the current location of the cursor in the file

SEEK_END whence in fseek()

starts the offset from the end of the file

#if

tests if a compile time condition is true

#else

the alternative of #if

what are enumerations mainly used for

to assign names to integral constants

all enum constants must be unique in their scope true/false

true

c programming does not provide direct support for error handling true/false

true

enumeration is a user defined data type true/false

true

two enum names can have the same value true/false

true

fread() & fwrite()

used for reading from and writing to a file on the disk respectively in case of binary files

A value of _____ indicates that there is no error in the program

zero


संबंधित स्टडी सेट्स

Question Set 1, Question Set 2, Question Set 3, Question Set 4, Question Set 5, Question Set 6, Question Set 8

View Set

fin 240 kaplowitz worksheet 37.3: limited liability partnerships and limited partnerships

View Set

U.S. History: Industrial Revolution

View Set

National Electric Code. (NEC) Article 430. Motors, Motor Circuits, & Controllers.

View Set

Немецкие идиомы и их русские аналоги

View Set

Biomechanics Final Exam Review Questions

View Set