INPR

Subdecks (1)

Cards (40)

  • Input

    To send information to a computer for processing
  • Output
    To display information or results after processing
  • File
    A collection of data stored in one unit, identified by a filename
  • How to Open a File
    1. File Pointer
    2. Fopen - Fclose
  • File Pointer
    Initializes an object of the type FILE, which contains all the information necessary to control the stream
  • Fopen - Fclose
    FILE *fp;
    FILE *fopen( const char * filename, const char * mode );
    fp = fopen("fileName", "w");
  • fprintf()
    Function used to write set of characters into file. Sends formatted output to a stream.
  • fscanf()
    Function used to read set of characters from file. Reads a word from the file and returns EOF at the end of file.
  • fputc()
    Function used to write a single character into file. Outputs a character to a stream.
  • fgetc()
    Function returns a single character from the file. Gets a character from the stream. Returns EOF at the end of file.
  • fputs()
    Function writes a line of characters into file. Outputs string to a stream.
  • Exception handling is designed to process synchronous errors, which occur when a statement executes
  • Exception handling is not designed to process errors associated with asynchronous events
  • Classic 'C' Approach to EXCEPTION handling
    Each function returns a value indicating success or failure
    Every function must check the return code of every function call it makes and take care of errors
    Exceptions make it easy to separate error handling from the rest of the code
  • Methods of EXCEPTION Handling
    If-else method
    setjmp() and longjmp()
  • If-else method
    Exception is handled by making decisions via if – else
    Occurrence of an exception is checked by the return values of a function or by defined parameters
    Along with that condition is placed an if – else statement that checks and performs the respective action against that exception
  • setjmp() and longjmp()
    Used to jump away from a particular location in a program into another function
    The programmer written code, inside that function handles the exception
    To test the occurrence of an exception the setjmp() functions is called up
    Setjmp() saves the most recent event of the program before that statement in a buffer called jmp buff
    As soon as the exception test is complete the setjmp() returns a value to the function
    If the value returned from the setjmp() to the longjmp() is '0' it means that there was an exception condition
    Now the program will start again from the same point where it stopped (saves in the buffer), until the exception condition is removed or repaired