(CMPUT) 201 - Department of Computing Science - University of ...
(CMPUT) 201 - Department of Computing Science - University of ...
(CMPUT) 201 - Department of Computing Science - University of ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Key Points<strong>CMPUT</strong> <strong>201</strong>Key PointsPreparing forLabsOverviewKeep in mind:1 The course has an emphasis on C (not C++) underUnix.2 Some C++ topics will be covered.3 Three assignments. Each assignment builds uponearlier ones.4 Collaboration (within limits) allowed on assignments.Read the fine print on course policy.5 There is a lab examination.
Labs and Accounts<strong>CMPUT</strong> <strong>201</strong>Key PointsPreparing forLabsOverviewLabs start next week, January 15.Make sure that:1 Before your lab, get your Unix accounts from Lab Adminand log in.http://ugweb.cs.ualberta.ca/accounts.htmlBring your ONE cardRead and sign the Conditions <strong>of</strong> Use2 Go before your lab time. Try to log in beforehand.3 Bring your King and Sobell textbooks to your labs
Goals <strong>of</strong> <strong>CMPUT</strong> <strong>201</strong><strong>CMPUT</strong> <strong>201</strong>Key PointsPreparing forLabsOverviewGoals:1 Teach the C programming language and modelsyntax, memory, debugging, execution2 Teach the Unix programming modelstandard in-out-error, pipes, basic API3 Teach some, practical aspects <strong>of</strong> programmingmethodologycommon modularization techniques, value <strong>of</strong> simplicity,assertions, source code version controlNon-Goals:1 We assume knowledge <strong>of</strong> abstraction andobject-oriented design2 We assume you know Java
How to succeed in <strong>CMPUT</strong> <strong>201</strong><strong>CMPUT</strong> <strong>201</strong>Key PointsPreparing forLabsOverview1 Be fearless in “just trying it out”. It is hard to do anypermanent damage, if you use backups and versioncontrol.Write small programs to test out concepts2 Learn to find the answers for yourself.Your textbooks are excellent resourcesman pages are your friendGoogle your compiler error messagesthe Web knows (almost) all3 Learn how to use the debugger.
How to fail/drown in <strong>CMPUT</strong> <strong>201</strong><strong>CMPUT</strong> <strong>201</strong>Key PointsPreparing forLabsOverviewNOTE: The following points are intended to be ironic.1 Continue to do things (i.e., write and debug) programsjust as you have always done.2 Wait more than a year between taking <strong>CMPUT</strong> 115 to<strong>CMPUT</strong> <strong>201</strong>.3 Do not learn how to use the debugger.4 Do not take advantage <strong>of</strong> labs to ask questions <strong>of</strong> yourTAs5 Take <strong>201</strong> because “I am interested in learning a bitmore about how programming is done”. In fact, <strong>201</strong> isintended to help you master programming in C underUnix.<strong>201</strong> is about “doing art” and not “art appreciation”.
Major Themes in <strong>CMPUT</strong> <strong>201</strong><strong>CMPUT</strong> <strong>201</strong>Key PointsPreparing forLabsOverview1 Often, there’s more than one way to do something.Have a good set <strong>of</strong> tools and techniques.“If all you have is a hammer, then everything looks like anail."2 Clear and simple should be preferred over clever andcomplex.3 The difference between spending 10 hours vs. 100hours on an assignment will come down to “bestpractices”.debugger, makefiles, assertions, “throw away” testprograms, incremental testing, automating repetitivetasksstart assignments on-timeTry to understand what you are doing, instead <strong>of</strong> justgetting something to work.
A Vertical Strip Example: Running Programs<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>wget http://www.cs.ualberta.ca/~paullu/C<strong>201</strong>/sketchpad...snip...paullu@ug30:~/C<strong>201</strong>>wget http://www.cs.ualberta.ca/~paullu/C<strong>201</strong>/example.a1.sketchpad...snip...paullu@ug30:~/C<strong>201</strong>>ls -lttotal 96-rw------- 1 paullu pr<strong>of</strong> 92418 Sep 6 15:42 sketchpad-rw------- 1 paullu pr<strong>of</strong> 170 Sep 6 15:41 example.a1.sketchpadpaullu@ug30:~/C<strong>201</strong>>chmod +x ./sketchpadpaullu@ug30:~/C<strong>201</strong>>ls -lttotal 96-rwx------ 1 paullu pr<strong>of</strong> 92418 Sep 6 15:42 sketchpad*-rw------- 1 paullu pr<strong>of</strong> 170 Sep 6 15:41 example.a1.sketchpadpaullu@ug30:~/C<strong>201</strong>>./sketchpad < example.a1.sketchpadNOTE: For all the notes, file sizes and timestamps maydiffer from reality.1 The Unix shell (e.g., bash, tcsh) prompts the user forcommands to execute with paullu@ug302 wget, ls, and sketchpad are all programs executedfrom the command line <strong>of</strong> the shell.Unix is <strong>of</strong>ten used via the command-line interface
man pages<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File ContentsManual (man) pages are the traditional, on-linedocuments for Unix.man wget: details for a specific programman -k http: does a (lame) search using http askeywordman man: details how to use manOften, Unix commands have esoteric command-lineoptions. For example, ls -lt.ls: the “list directory contents” program-l: long listing format-t: sort by the timestamp
Compiling Programs<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>ls -lttotal 100-rw------- 1 paullu pr<strong>of</strong> 2072 Sep 7 00:17 finddw.cpaullu@ug30:~/C<strong>201</strong>>gcc -Wall -ansi finddw.c -o finddw...snip (some compiler warnings)...paullu@ug30:~/C<strong>201</strong>>ls -lttotal 116-rwx------ 1 paullu pr<strong>of</strong> 14391 Sep 7 00:19 finddw*-rw------- 1 paullu pr<strong>of</strong> 2072 Sep 7 00:17 finddw.c1 Suppose you have a C program in file finddw.c (for“find double word”)2 A program is compiled using a compiler, such as gcc3 -Wall -ansi are command-line options for gcc.They are also called compiler options.4 -o finddw specifies the name <strong>of</strong> the executable file.Default name is a.out
Running Find Double Word<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>cat finddw.testSometimes, it is is easy towrite the same word twicetwice and not make a spelling mistake.paullu@ug30:~/C<strong>201</strong>>./finddw finddw.testIn file finddw.test, repeated word: is isContext: easy toRe-run program after fixing!!!In file finddw.test, repeated word: twice twiceContext: and not make a spelling mistake.Re-run program after fixing!!!paullu@ug30:~/C<strong>201</strong>>cat finddw.okThis file is fine.There is nothing to worry about.paullu@ug30:~/C<strong>201</strong>>./finddw finddw.okpaullu@ug30:~/C<strong>201</strong>>cat is a program to send the contents <strong>of</strong> a file to theterminalfinddw knows which file to use from the command-lineargument
Find Double Word<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>cat finddw.c#include #include /* For strncmp(), etc. */#define MIN_BUF 256#define MAX_BUF 2048char Buffer[ MAX_BUF ];char Word[ MIN_BUF ];char NextWord[ MIN_BUF ];void parseFile( FILE * fp, char * fname );(code listing continues on later slides)Before the executable code, a best practice is to list:header files (#include)(macro) definitions (#define)global variablesfunction prototypes
Find Double Word (2)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentsint main( int argc, char * argv[] ){int i;FILE * fp;for( i = 1; i < argc; i++ ){fp = fopen( argv[ i ], "r" );if( fp == NULL ){printf( "Could not open file %s\n", argv[ i ] );exit( -1 );}else{}}return( 0 );} /* main */parseFile( fp, argv[ i ] );fclose( fp );(code listing continues on later slides)The main() function is where the program starts executing. The Unix shellfinds the executable and starts running it at function main().main() is a function, not a method. But, it has similar syntax in its functiondefinition compared to Java.
Find Double Word (3)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentsint main( int argc, char * argv[] ){int i;FILE * fp;for( i = 1; i < argc; i++ ){fp = fopen( argv[ i ], "r" );if( fp == NULL ){printf( "Could not open file %s\n", argv[ i ] );exit( -1 );}else{parseFile( fp, argv[ i ] );fclose( fp );}}return( 0 );} /* main */(code listing continues on later slides)Local variables (e.g., int i, FILE * fp) are defined before being usedFor loops (e.g., for( ... )) are similar to JavaControl flow (e.g., if() ... else) is similar to Java
Find Double Word (4)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentsint main( int argc, char * argv[] ){int i;FILE * fp;for( i = 1; i < argc; i++ ){fp = fopen( argv[ i ], "r" );if( fp == NULL ){printf( "Could not open file %s\n", argv[ i ] );exit( -1 );}else{parseFile( fp, argv[ i ] );fclose( fp );}}return( 0 );} /* main */(code listing continues on later slides)function calls (e.g., fopen(), parseFile(), fclose()) are similar toJavaC input/output is by the Standard I/O (stdio) library (e.g., printf())
Find Double Word (5)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentsvoid parseFile( FILE * fp, char * fname ){int rval;/* Read first word */rval = fscanf( fp, "%s", Word );if( rval != 1 ){printf( "Failed to read first word\n" );exit( -1 );}(code listing continues on later slides)comments should be used (e.g., /* Read first word */) to explain thesemantics, not the syntax90% <strong>of</strong> the time, clear code that follows standard conventions is preferredover clever codeC input is by the Standard I/O (stdio) library (e.g., fscanf())
Find Double Word (6)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentswhile( ! fe<strong>of</strong>( fp ) ){rval = fscanf( fp, "%s", NextWord );if( rval != 1 )continue;if( strncmp( Word, NextWord, MIN_BUF ) == 0 ){printf( "In file %s, repeated word: %s %s\n",fname, Word, NextWord );}/* Heuristic as to when to print out context info *//* First letter must be alphabets */if( isalpha( Word[ 0 ] ) ){fgets( Buffer, MAX_BUF, fp );printf( "Context: %s\n", Buffer );printf( "Re-run program after fixing!!!\n " );}strncpy( Word, NextWord, MIN_BUF );} /* while */} /* parseFile */While loops (e.g., while( ... )) are similar to JavaC strings are handled using a family <strong>of</strong> functions (e.g., strncmp(),strncpy())
Makefiles<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>cat Makefile# A simple makefilefinddw: finddw.cgcc -Wall -ansi finddw.c -o finddwpaullu@ug30:~/C<strong>201</strong>>makegcc -Wall -ansi finddw.c -o finddw1 By default, the program make looks for Makefile ormakefile (which are text files).2 Makefiles are examples <strong>of</strong> declarative programs: Youtell the system what you want, more than how toachieve it. In truth, it is a hybrid <strong>of</strong> declarative andimperative.3 First Common Pitfall: The white space in front <strong>of</strong> gcc-Wall ... is actually an invisible tab.
Makefiles (2)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>cat Makefile# A simple makefilefinddw: finddw.cgcc -Wall -ansi finddw.c -o finddwpaullu@ug30:~/C<strong>201</strong>>makegcc -Wall -ansi finddw.c -o finddw1 finddw: finddw.c:1 Defines a makefile target (i.e., finddw) and its (list <strong>of</strong>)dependencies (i.e., finddw.c) (aka prerequisite-list).2 A makefile can have multiple targets.3 The dependencies can be files, or other targets.2 TAB gcc -Wall -ansi finddw.c -o finddw1 Defines an action (aka construction-commands).2 Actions are anything that you can do from the Unixcommand line.
Make Execution Model<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>cat Makefile# A simple makefilefinddw: finddw.cgcc -Wall -ansi finddw.c -o finddwpaullu@ug30:~/C<strong>201</strong>>makegcc -Wall -ansi finddw.c -o finddw1 In this example, make and make finddw have thesame effect.2 When you execute make1 Make looks for a makefile.2 Make looks for your target (e.g., finddw) or uses thefirst one by default.3 Make looks at the timestamps (cf. ls -lt) on thetarget and the dependencies.4 If the target is more recent than the dependencies, thenmake does nothing more.
Make Execution Model (2)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>cat Makefile# A simple makefilefinddw: finddw.cgcc -Wall -ansi finddw.c -o finddwpaullu@ug30:~/C<strong>201</strong>>makegcc -Wall -ansi finddw.c -o finddw1 If the target is less recent than the dependencies, or ifthe target does not exist, then make invokes the targetsfor the dependencies (if any).2 Then, make invokes the actions for the current target.3 Second Common Pitfall: It is easy to forget adependency for a target, especially when refactoringcode. Solution: Be careful. And, have a make cleantarget, as discussed below.
Make Execution Model (3)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>makegcc -Wall -ansi finddw.c -o finddwpaullu@ug30:~/C<strong>201</strong>>makemake: ‘finddw’ is up to date.paullu@ug30:~/C<strong>201</strong>>touch finddw.cpaullu@ug30:~/C<strong>201</strong>>makegcc -Wall -ansi finddw.c -o finddwpaullu@ug30:~/C<strong>201</strong>>which whichwhich: shell built-in command.paullu@ug30:~/C<strong>201</strong>>which touch/usr/bin/touch1 touch is a Unix command that “updates” thetimestamp <strong>of</strong> a file to, for example, simulate editing afile. The contents <strong>of</strong> the file does not change.2 Notice how make’s declarative execution model onlylooks at timestamps, and does not look at the contents<strong>of</strong> a file.3 which is a Shell command to tell you where (or which)an executable is located
Make Execution Model (4)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, Compilingpaullu@ug30:~/C<strong>201</strong>>cat Makefile.v2finddw: finddw.cgcc -Wall -ansi finddw.c -o finddwFind Double WordMakefilesCompiler Warningsclean:-rm *.o finddwOtherExamplespopen: ChildProcessesBuffer File Contentstar:tar cvf submit.tar finddw.c Makefile READMEMakefiles are useful for more than just building programs.Anything that can be automated as a sequence <strong>of</strong> actionsand/or targets and dependencies can be automated via aMakefile.Target clean is a common target (and required in yourassignments). Note that you should never have a file withthe name clean.
Make Execution Model (5)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>cat Makefile.v2finddw: finddw.cgcc -Wall -ansi finddw.c -o finddwclean:tar:-rm *.o finddwtar cvf submit.tar finddw.c Makefile READMEThe -rm ... removes files that can be (and should be)re-created from other files.For example, .o files are created from .c files (morelater).For example, executable finddw is created from .cfiles.The - in front <strong>of</strong> rm says, “If the action should fail in anyway, continue with the next action”
Make Execution Model (6)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>make -f Makefile.v2 cleanrm *.o finddwrm: cannot remove ‘*.o’: No such file or directorymake: [clean] Error 1 (ignored)paullu@ug30:~/C<strong>201</strong>>make -f Makefile.v2gcc -Wall -ansi finddw.c -o finddwpaullu@ug30:~/C<strong>201</strong>>touch READMEpaullu@ug30:~/C<strong>201</strong>>make -f Makefile.v2 tartar cvf submit.tar finddw.c Makefile READMEfinddw.cMakefileREADME1 Target tar automates the error-prone command tocreate a tape archive (tar) file.The cvf command-line options say: create a new tarfile, be verbose when doing so, and use the filenamethat follows immediately after the cvf (i.e.,submit.tar).After the cvf submit.tar is the list <strong>of</strong> files to put intothe tar file.2 Common Pitfall: It is a big mistake to do somethinglike: tar cvf finddw.c Makefile README.
Make Execution Model (7)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>cat Makefile.v3finddw: finddw.ogcc -Wall -ansi finddw.o -o finddwfinddw.o: finddw.cgcc -Wall -ansi -c finddw.cclean:-rm *.o finddwtar:tar cvf submit.tar finddw.c Makefile READMEpaullu@ug30:~/C<strong>201</strong>>make -f Makefile.v3 finddw.ogcc -Wall -ansi -c finddw.cpaullu@ug30:~/C<strong>201</strong>>ls -lt *.o-rw------- 1 paullu pr<strong>of</strong> 2020 Sep 11 18:09 finddw.opaullu@ug30:~/C<strong>201</strong>>make -f Makefile.v3 finddwgcc -Wall -ansi finddw.o -o finddwpaullu@ug30:~/C<strong>201</strong>>ls -lt finddw*-rwx------ 1 paullu pr<strong>of</strong> 14391 Sep 11 18:09 finddw*-rw------- 1 paullu pr<strong>of</strong> 2020 Sep 11 18:09 finddw.o-rw------- 1 paullu pr<strong>of</strong> 2072 Sep 11 16:35 finddw.c-rw------- 1 paullu pr<strong>of</strong> 52 Sep 9 01:15 finddw.ok-rw------- 1 paullu pr<strong>of</strong> 93 Sep 9 01:08 finddw.testpaullu@ug30:~/C<strong>201</strong>>make -f Makefile.v3 cleanrm *.o finddwpaullu@ug30:~/C<strong>201</strong>>make -f Makefile.v3gcc -Wall -ansi -c finddw.cgcc -Wall -ansi finddw.o -o finddwpaullu@ug30:~/C<strong>201</strong>>
Make Execution Model (8)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>cat Makefile.v3finddw: finddw.ogcc -Wall -ansi finddw.o -o finddwfinddw.o: finddw.cgcc -Wall -ansi -c finddw.cclean:-rm *.o finddwtar:tar cvf submit.tar finddw.c Makefile READMEpaullu@ug30:~/C<strong>201</strong>>make -f Makefile.v3 finddw.ogcc -Wall -ansi -c finddw.cpaullu@ug30:~/C<strong>201</strong>>ls -lt *.o-rw------- 1 paullu pr<strong>of</strong> 2020 Sep 11 18:09 finddw.opaullu@ug30:~/C<strong>201</strong>>make -f Makefile.v3 finddwgcc -Wall -ansi finddw.o -o finddw...snip...The gcc -Wall -ansi -c illustrates separatecompilation in C.
Compiler Warnings<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>head -11 finddw.c#include #include /* For strncmp(), etc. */#define MIN_BUF 256#define MAX_BUF 2048char Buffer[ MAX_BUF ];char Word[ MIN_BUF ];char NextWord[ MIN_BUF ];void parseFile( FILE * fp, char * fname );paullu@ug30:~/C<strong>201</strong>>makegcc -Wall -ansi finddw.c -o finddwfirst.finddw.c: In function ‘main’:first.finddw.c:23: warning: implicit declaration <strong>of</strong> function ‘exit’first.finddw.c: In function ‘parseFile’:first.finddw.c:62: warning: implicit declaration <strong>of</strong> function ‘isalpha’1 As discussed earlier, the finddw program will generatecompiler warnings.2 Warnings are not the same, fatal things as errors. But,good programming style and methodology requires thatwarnings be fixed.
Compiler Warnings (2)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>head -2 finddw.c#include #include /* For strncmp(), etc. */paullu@ug30:~/C<strong>201</strong>>makegcc -Wall -ansi finddw.c -o finddwfirst.finddw.c: In function ‘main’:first.finddw.c:23: warning: implicit declaration <strong>of</strong> function ‘exit’first.finddw.c: In function ‘parseFile’:first.finddw.c:62: warning: implicit declaration <strong>of</strong> function ‘isalpha’paullu@ug30:~/C<strong>201</strong>>cat -n finddw.c | grep "^ *23"23 exit( -1 );paullu@ug30:~/C<strong>201</strong>>cat -n finddw.c | grep "^ *62"62 if( isalpha( Word[ 0 ] ) )1 The man page for exit() (i.e., man 3 exit) showsthat I need #include .At the end <strong>of</strong> man exit, there is a SEE ALSO sectionthat pointed me to exit(3), which is why we need todo man 3 exit.2 The man page for isalpha() (i.e., man isalpha)shows that I need #include .
Compiler Warnings (3)<strong>CMPUT</strong> <strong>201</strong>Vertical StripRunning, CompilingFind Double WordMakefilesCompiler WarningsOtherExamplespopen: ChildProcessesBuffer File Contentspaullu@ug30:~/C<strong>201</strong>>head -5 finddw.c#include #include /* For strncmp(), etc. */#include /* For exit(), etc. */#include /* For isalpha(), etc. */paullu@ug30:~/C<strong>201</strong>>makegcc -Wall -ansi finddw.c -o finddw1 The warnings have now been fixed.2 Remember, your main tools for this are:Man pagesGoogleYour textbooksYour TAs, instructor, and fellow students.