[prev] [index] [next]

Data (cont)

Ways to input data into a program:
  • stdin

    prompt$ ./floats
    Enter a number: 3.141593
    Enter a number: 2.718282
    The greater number is 3.141593
    

    • read data using scanf() or getchar() or fgets(...,stdin) etc.
    • can be redirected from files by < (on command line):

      prompt$ more xy.txt
      3.141593
      2.718282
      prompt$ ./floats < xy.txt
      Enter a number:
      Enter a number:
      The greater number is 3.141593
      

  • Files (Week 10)