SlideShare a Scribd company logo
rview: In this project, you will write a C program that utilizes command line arguments, file
reading, file writing, and iterating through two dimensional arrays. Restrictions: You may only
import stdio.h, stdlib.h and string.h You may not use any global variables. Premise: Jerry the
mouse has been captured by the evil scientist named Dr. Mays who has put him into a labyrinth.
Jerry does not know which way to go within the labyrinth and is now hungry as he has stayed in
place for some time. He smells some food nearby in the maze but is wary of wandering about
endlessly. Your task is to help Jerry find the food within the maze so that he can satisfy his
hunger. Overview: The maze has a grid layout with m x n rows and columns with the boundaries
of the maze being indicated by the '|' character. Within the maze, there are one or more locations
of food being indicated by the 'C' character. Also, Jerrys location is indicated at a random
location by the 'M' character with the whitespace character ' ' indicating positions within the
maze that Jerry can traverse. Consider the maze below: y x 1 1 11 1 1 1 36 1 The bottom left
boundary of the maze represents (x, y) coordinate (1,1) and the top right boundary of the maze
represents (x, y) coordinate (36, 11) Jerrys location within the maze is indicated by 'M' and his
(x, y) coordinate is (19, 9) Multiple cheeses (foods) are placed within the maze as indicated by
'C'. The (x, y) cheese coordinates are (3, 2), (10,4), and (28, 10) Instructions: Your source file
will be named p2__.c Your program will utilize command line arguments where two file names
will be provided on the command line as follows: ./p2__ input_file1.txt input_file2.txt Input
files: The first input file will be the maze that you will utilize in your program. This maze is used
by both the iterative search and the recursive search functions (see functions section for more
information) The second input file will contain multiple lines that contain one of the four
cardinal directions (N, E, S, W) that indicate directions that Jerry will take within the maze
during his iterative search but not during his recursive search. Assumptions: There will be at
least one cheese within the maze The input files will contain a single dot (.) and its extension
afterwards (txt, in, etc.) The length of a column for any particular maze will not exceed 50
characters Each maze will contain a random location in which Jerry is located Boundaries of the
maze are indicated by '|' Coordinates which can be traversed are indicated by ' ' (white space)
Mazes will contain at least a single path to a cheese (both iteratively and recursively) Cardinal
directions in the second input file will be each on their own line and will be a single valid capital
letter character representing N, E, S, W Mazes are fully enclosed, so Jerry cannot go out of
bounds of any given maze Rows of a given maze will have the same length Output: Your
program will produce two separate output files where the first output files name will start with
iterative_ and then you will concatenate the file name the first input files name but with the
extension .out. Within the first output file, it will contain the final maze where the maze indicates
the paths taken by Jerry, Jerrys final location, and the (x, y) directions that were taken by Jerry in
an iterative manner. The second output files name will start with recursive_ and then you will
concatenate the file name the first input files name but with the extension .out. Within the second
output, it will contain the final maze where the maze indicates the paths taken by Jerry, Jerrys
final location and the (x, y) directions that were taken by Jerry that only led to a cheese in a
recursive manner. Specific Requirements: Your program must verify that there are two files
input via command line arguments. If this condition is not held, then your program must print an
error message and exit the program. Your program must verify that the two input files can be
opened. If this condition is not held, then your program must print an error message and exit the
program. Required functions (in addition to main): You are free to choose any additional
parameters for both of the functions below void iterative_search(char ** maze, ) The function
utilizes the second input file from the command line arguments as directions that Jerry takes as
he iteratively traverses through the maze. This function keeps track of every (x, y) coordinate
that Jerry has visited on his search for the cheese. Indicate coordinates that have been visited by
the '.' character. Once Jerry finds a cheese or if there are no more directions that Jerry can take,
this function updates his final location in the maze. int recursive_search(char ** maze, ) This
function does not utilize the second input file from the command line arguments. For this
function, your output may differ based off how you recurse through the maze this is fine as long
as you find at least a cheese. This function returns 1 if the recursive search led to a cheese
otherwise it returns 0 to indicate that the path that Jerry was on did not lead to a cheese. This
function keeps track of the (x, y) coordinates that only led Jerry to a cheese. This function
Indicates coordinates that have been visited by the '.' character. Once Jerry finds a cheese, this
function updates his final location in the maze. Tips for recursively searching: Consider the
provided incomplete pseudocode as a starting point for your function: FUNCTION
RecursiveSearch (parameters: char pointer to pointer, ) IF current position contains food return
successful search ENDIF IF current position has been visited prior OR return not a successful
search ENDIF FOR ENDFOR ENDFUNCTION
Sample Runs: [hmughal2@zeus-2 p2]$ ./p2 Error - two input files were not provided as
command line arguments [hmughal2@zeus-2 p2]$ ./p2 labryinth.txt Error - two input files were
not provided as command line arguments [hmughal2@zeus-2 p2]$ ./p2 labrynth.txt directions.txt
Error the labrynth.txt file could not be opened [hmughal2@zeus-2 p2]$ ./p2 labryinth.txt abc.txt
Error the abc.txt file could not be opened [hmughal2@zeus-2 p2]$ ./p2 labryinth.txt
directions.txt Success two output files iterative_labryinth.out and recursive_labryinth.out
produced iterative_labryinth.out and recursive_labryinth.out (see Blackboard for output files)
Both .out files contain the output maze as traversed by Jerry iteratively and recursively
respectively with coordinates traversed being indicated by '.'. Both output mazes indicate Jerrys
final coordinate. Additionally, after the final output mazes there are directions taken by Jerry that
indicate the coordinates taken where coordinates are in the (x, y) format. In the instance of the
iterative search, the output contains every direction (after the final output maze) that Jerry took in
the cardinal direction with the x and y coordinate. In the instance of the recursive search, the
output contains after the final output maze) ONLY the cardinal directions that led Jerry to a
cheese location (NOT every direction that Jerry took).

More Related Content

PDF
In this project you will write a C program that utilizes co.pdf
PDF
Practice exam php
PPTX
Functions2.pptx
PDF
Data Analysis with R (combined slides)
PPT
python language programming presentation
PDF
C standard library functions
PPTX
cbse class 12 Python Functions2 for class 12 .pptx
PPTX
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
In this project you will write a C program that utilizes co.pdf
Practice exam php
Functions2.pptx
Data Analysis with R (combined slides)
python language programming presentation
C standard library functions
cbse class 12 Python Functions2 for class 12 .pptx
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...

Similar to rview In this project, you will write a C program that utilizes com.pdf (20)

PPTX
Python Workshop - Learn Python the Hard Way
PDF
Python 2.5 reference card (2009)
PDF
Fibonacci Function Gallery - Part 2 - One in a series
PDF
Functional programming ii
DOCX
Java execise
PDF
Functions2.pdf
PPTX
Introduction to Python , Overview
PPTX
Programming in C sesion 2
PDF
Lambda? You Keep Using that Letter
PDF
Ti1220 Lecture 7: Polymorphism
PPTX
Using-Python-Libraries.9485146.powerpoint.pptx
PDF
For this project, you will design and implement a simple command-lin.pdf
PDF
Functions_21_22.pdf
DOCX
ECS 60 Programming Assignment #1 (50 points) Winter 2016 .docx
DOCX
UNIT 4-HEADER FILES IN C
PDF
Chapter Functions for grade 12 computer Science
PDF
Lecture 5: Functional Programming
PPS
C programming session 08
PPTX
2 Functions2.pptx
Python Workshop - Learn Python the Hard Way
Python 2.5 reference card (2009)
Fibonacci Function Gallery - Part 2 - One in a series
Functional programming ii
Java execise
Functions2.pdf
Introduction to Python , Overview
Programming in C sesion 2
Lambda? You Keep Using that Letter
Ti1220 Lecture 7: Polymorphism
Using-Python-Libraries.9485146.powerpoint.pptx
For this project, you will design and implement a simple command-lin.pdf
Functions_21_22.pdf
ECS 60 Programming Assignment #1 (50 points) Winter 2016 .docx
UNIT 4-HEADER FILES IN C
Chapter Functions for grade 12 computer Science
Lecture 5: Functional Programming
C programming session 08
2 Functions2.pptx
Ad

More from alokindustries1 (20)

PDF
Select the TRUE statement Group of answer choicesA. An arthropod�.pdf
PDF
Select one of the scenarios listed below and explain the best soluti.pdf
PDF
Select the combination of the following statements relating to sourc.pdf
PDF
select each of the following which relate to the term homozygous .pdf
PDF
Select the combination of the following statements regarding stakeho.pdf
PDF
select each of the following which relate to the term heterozygous.pdf
PDF
Select all that are true regarding Economic Value Added (EVA) a) .pdf
PDF
Select the case that would most likely be filed under disparate impa.pdf
PDF
Select all that are true about plasmid DNA.a.The DNA in plasmids.pdf
PDF
Select a current event (local or international) that is relevant to .pdf
PDF
Seleccione SOLO UNO de los siguientes Objetivos de Desarrollo Sosten.pdf
PDF
Seleccione todas las cualidades que pertenecen a los sistemas parlam.pdf
PDF
Seleccione la declaraci�n FALSA de las siguientes A. Trabajar con o.pdf
PDF
Seismic waves travel faster when the rock is less stiff.A) TrueB.pdf
PDF
Seg�n TCPS 2, �qu� es la investigaci�n de riesgo m�nimo (seleccione .pdf
PDF
Seg�n Juan Linz (1990), �c�mo los sistemas presidenciales crean disc.pdf
PDF
Seg�n Holton en la fuente 1, �cu�les fueron los motivos de los padre.pdf
PDF
Seg�n el texto, �qu� es un factor Persona a la que se le da autori.pdf
PDF
Security X has an actual rate of return of 11.8 and a beta of 0.72..pdf
PDF
Seg�n el C�digo y las Normas, �cu�l de las siguientes afirmaciones c.pdf
Select the TRUE statement Group of answer choicesA. An arthropod�.pdf
Select one of the scenarios listed below and explain the best soluti.pdf
Select the combination of the following statements relating to sourc.pdf
select each of the following which relate to the term homozygous .pdf
Select the combination of the following statements regarding stakeho.pdf
select each of the following which relate to the term heterozygous.pdf
Select all that are true regarding Economic Value Added (EVA) a) .pdf
Select the case that would most likely be filed under disparate impa.pdf
Select all that are true about plasmid DNA.a.The DNA in plasmids.pdf
Select a current event (local or international) that is relevant to .pdf
Seleccione SOLO UNO de los siguientes Objetivos de Desarrollo Sosten.pdf
Seleccione todas las cualidades que pertenecen a los sistemas parlam.pdf
Seleccione la declaraci�n FALSA de las siguientes A. Trabajar con o.pdf
Seismic waves travel faster when the rock is less stiff.A) TrueB.pdf
Seg�n TCPS 2, �qu� es la investigaci�n de riesgo m�nimo (seleccione .pdf
Seg�n Juan Linz (1990), �c�mo los sistemas presidenciales crean disc.pdf
Seg�n Holton en la fuente 1, �cu�les fueron los motivos de los padre.pdf
Seg�n el texto, �qu� es un factor Persona a la que se le da autori.pdf
Security X has an actual rate of return of 11.8 and a beta of 0.72..pdf
Seg�n el C�digo y las Normas, �cu�l de las siguientes afirmaciones c.pdf
Ad

Recently uploaded (20)

PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
01-Introduction-to-Information-Management.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Lesson notes of climatology university.
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
A systematic review of self-coping strategies used by university students to ...
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
01-Introduction-to-Information-Management.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Computing-Curriculum for Schools in Ghana
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Final Presentation General Medicine 03-08-2024.pptx
Microbial disease of the cardiovascular and lymphatic systems
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Lesson notes of climatology university.
Supply Chain Operations Speaking Notes -ICLT Program
Microbial diseases, their pathogenesis and prophylaxis
2.FourierTransform-ShortQuestionswithAnswers.pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Abdominal Access Techniques with Prof. Dr. R K Mishra
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student

rview In this project, you will write a C program that utilizes com.pdf

  • 1. rview: In this project, you will write a C program that utilizes command line arguments, file reading, file writing, and iterating through two dimensional arrays. Restrictions: You may only import stdio.h, stdlib.h and string.h You may not use any global variables. Premise: Jerry the mouse has been captured by the evil scientist named Dr. Mays who has put him into a labyrinth. Jerry does not know which way to go within the labyrinth and is now hungry as he has stayed in place for some time. He smells some food nearby in the maze but is wary of wandering about endlessly. Your task is to help Jerry find the food within the maze so that he can satisfy his hunger. Overview: The maze has a grid layout with m x n rows and columns with the boundaries of the maze being indicated by the '|' character. Within the maze, there are one or more locations of food being indicated by the 'C' character. Also, Jerrys location is indicated at a random location by the 'M' character with the whitespace character ' ' indicating positions within the maze that Jerry can traverse. Consider the maze below: y x 1 1 11 1 1 1 36 1 The bottom left boundary of the maze represents (x, y) coordinate (1,1) and the top right boundary of the maze represents (x, y) coordinate (36, 11) Jerrys location within the maze is indicated by 'M' and his (x, y) coordinate is (19, 9) Multiple cheeses (foods) are placed within the maze as indicated by 'C'. The (x, y) cheese coordinates are (3, 2), (10,4), and (28, 10) Instructions: Your source file will be named p2__.c Your program will utilize command line arguments where two file names will be provided on the command line as follows: ./p2__ input_file1.txt input_file2.txt Input files: The first input file will be the maze that you will utilize in your program. This maze is used by both the iterative search and the recursive search functions (see functions section for more information) The second input file will contain multiple lines that contain one of the four cardinal directions (N, E, S, W) that indicate directions that Jerry will take within the maze during his iterative search but not during his recursive search. Assumptions: There will be at least one cheese within the maze The input files will contain a single dot (.) and its extension afterwards (txt, in, etc.) The length of a column for any particular maze will not exceed 50 characters Each maze will contain a random location in which Jerry is located Boundaries of the maze are indicated by '|' Coordinates which can be traversed are indicated by ' ' (white space) Mazes will contain at least a single path to a cheese (both iteratively and recursively) Cardinal directions in the second input file will be each on their own line and will be a single valid capital letter character representing N, E, S, W Mazes are fully enclosed, so Jerry cannot go out of bounds of any given maze Rows of a given maze will have the same length Output: Your program will produce two separate output files where the first output files name will start with iterative_ and then you will concatenate the file name the first input files name but with the extension .out. Within the first output file, it will contain the final maze where the maze indicates the paths taken by Jerry, Jerrys final location, and the (x, y) directions that were taken by Jerry in
  • 2. an iterative manner. The second output files name will start with recursive_ and then you will concatenate the file name the first input files name but with the extension .out. Within the second output, it will contain the final maze where the maze indicates the paths taken by Jerry, Jerrys final location and the (x, y) directions that were taken by Jerry that only led to a cheese in a recursive manner. Specific Requirements: Your program must verify that there are two files input via command line arguments. If this condition is not held, then your program must print an error message and exit the program. Your program must verify that the two input files can be opened. If this condition is not held, then your program must print an error message and exit the program. Required functions (in addition to main): You are free to choose any additional parameters for both of the functions below void iterative_search(char ** maze, ) The function utilizes the second input file from the command line arguments as directions that Jerry takes as he iteratively traverses through the maze. This function keeps track of every (x, y) coordinate that Jerry has visited on his search for the cheese. Indicate coordinates that have been visited by the '.' character. Once Jerry finds a cheese or if there are no more directions that Jerry can take, this function updates his final location in the maze. int recursive_search(char ** maze, ) This function does not utilize the second input file from the command line arguments. For this function, your output may differ based off how you recurse through the maze this is fine as long as you find at least a cheese. This function returns 1 if the recursive search led to a cheese otherwise it returns 0 to indicate that the path that Jerry was on did not lead to a cheese. This function keeps track of the (x, y) coordinates that only led Jerry to a cheese. This function Indicates coordinates that have been visited by the '.' character. Once Jerry finds a cheese, this function updates his final location in the maze. Tips for recursively searching: Consider the provided incomplete pseudocode as a starting point for your function: FUNCTION RecursiveSearch (parameters: char pointer to pointer, ) IF current position contains food return successful search ENDIF IF current position has been visited prior OR return not a successful search ENDIF FOR ENDFOR ENDFUNCTION Sample Runs: [hmughal2@zeus-2 p2]$ ./p2 Error - two input files were not provided as command line arguments [hmughal2@zeus-2 p2]$ ./p2 labryinth.txt Error - two input files were not provided as command line arguments [hmughal2@zeus-2 p2]$ ./p2 labrynth.txt directions.txt Error the labrynth.txt file could not be opened [hmughal2@zeus-2 p2]$ ./p2 labryinth.txt abc.txt Error the abc.txt file could not be opened [hmughal2@zeus-2 p2]$ ./p2 labryinth.txt directions.txt Success two output files iterative_labryinth.out and recursive_labryinth.out produced iterative_labryinth.out and recursive_labryinth.out (see Blackboard for output files) Both .out files contain the output maze as traversed by Jerry iteratively and recursively respectively with coordinates traversed being indicated by '.'. Both output mazes indicate Jerrys final coordinate. Additionally, after the final output mazes there are directions taken by Jerry that
  • 3. indicate the coordinates taken where coordinates are in the (x, y) format. In the instance of the iterative search, the output contains every direction (after the final output maze) that Jerry took in the cardinal direction with the x and y coordinate. In the instance of the recursive search, the output contains after the final output maze) ONLY the cardinal directions that led Jerry to a cheese location (NOT every direction that Jerry took).