Standard IO: Basic IO

Standard Input/Output
  • Standard I/O

    • Its functions are to handle inputs, outputs, and errors
    • Standard input is usually from keyboard
    • Standard output is usually the monitor (via console, or terminal)
    • Error is normally output to the monitor (via console, or terminal)
  • Standard Output (basics)

    • The printf(“”, value) function allows the user to write values of various types
    • To use the printf method, you need to have the #include <stdio.h> preprocessor directive
    • Usage example: printf("Hello"); Or printf(“control string”, value);
    • Error is normally output to the monitor (via console, or terminal)
  • Standard Input (basics)

    • The scanf(“”, &var) function allows the user to read values of various types
    • To use the scanf method, you need to have the #include <stdio.h> preprocessor directive
    • Usage example: int x;
      scanf(“%d”, &x);
  • Ses1InputOutput project source code

    #include <stdio.h>

    #include <stdlib.h>

     

    int main(int argc, char *argv[]) {

        printf("Welcome to vtgames anyone can code C\n");

        printf("Please input a number: ");

        int x;

        scanf("%d", &x);

        printf("You have input: %d\n", x);

        return 0;

    }