8 Intermediate C Programming
You need to write a program that produces correct outputs based on given inputs.
This is frequently the case when taking programming courses. The correctness of the
program is evaluated by whether your program produces correct outputs. In many
cases, the programs are graded by computer programs based on the input-output
pairs. In this case, nobody reads the information on a computer screen.
If > and a file name is added after the command, then the output is saved in that file.
$ ./prog abc 123 C Programs > output
Nothing appears on the computer screen because the information is redirected to the
file whose name is output. You can use a text editor to see the contents of this file. You
can also use the Linux command more or less or cat to see the file’s content. If you type
more output in the terminal, this is what appears on the computer screen:
main: a = 5, b = 17, argc = 5
Since the output is saved in a file, you can use the diff command to check whether
that output is the same as the correct output, assuming you have the correct output saved
in another file. The diff command requires the names of two files and determines whether
these files are the same or not. If they are different, the command shows the line-by-line
differences. The diff program will compare the files exactly. It is often useful to ignore
whitespace and this can be done by adding -w after diff. Adding -q after diff shows only
whether the files are different or not, without showing the line-by-line differences. Although
the diff command is useful, sometimes we want to see the differences side-by-side. The
meld program in Linux does precisely that.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset