Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The things below are from the lab template. main.cpp = #include process2DArrayHeader.h int main() { std::string filename=matrix.txt; std::ifstream inFile; char symbol = '$'; char matrix[SIZE][SIZE];

image text in transcribed

The things below are from the lab template.

main.cpp =

#include "process2DArrayHeader.h"

int main() { std::string filename="matrix.txt"; std::ifstream inFile; char symbol = '$'; char matrix[SIZE][SIZE]; bool ok=false; //open the file ok = openFile(filename, inFile); //if open successfully if (ok){ // populate the matrix fillArray(inFile,matrix); // display the matrix displayArray(matrix); //search and display location of symbol if found searchSpecialSymbol(matrix,symbol); } else std::cout

matrix.txt =

AXDW $1dq SF2X SE$z

process2DArrayFunctions =

#include "process2DArrayHeader.h" //check if file is available

bool openFile( std::string filename, std::ifstream &inFile){ inFile.open(filename); if (inFile.fail()) return false; else return true;

}

//populate the displayArray

void fillArray(std::ifstream &inFile,char matrix[SIZE][SIZE] ){ for (int row=0;row>matrix[row][col]; } } } //displayArray void displayArray(char matrix[SIZE][SIZE]){ // traverse the matrix and display the matrix. //give a space in the output between characters

} //read the data sets from the file void searchSpecialSymbol(char matrix[SIZE][SIZE], char symbol){ //search the two d matrix for the symbol // std::cout

process2DArrayHeader =

#include #include #include #include const int SIZE=4; using std::string; bool openFile(std::string filename, std::ifstream &inFile); void fillArray(std::ifstream &inFile,char matrix[SIZE][SIZE]); void displayArray(char matrix[SIZE][SIZE]); void searchSpecialSymbol(char matrix[SIZE][SIZE], char symbol);

Problem You need to write a program that creates a two-dimensional array of character type. The program creates a 4 x 4 array and populates the array by reading data character by character from a data file into the array. The program prints the array as a matrix as given in the output and searches for a special character ('$") If the character is found it displays the row and column number where it was found You are given The lab template consisting of the file process 2DArrayFunctions.cpp, process2DArrayHeader.h, process2DMain.cpp What to do Use the given lab template. Populate the functions fillArray() and search SpecialSymbol) Include documentation for the program with header and line comments. If using makefile (Optional) Create a makefile with the command g++ process2DArrayFunctions.cpp, process2DArrayHeader.h, process2DArrayMain.cpp -o process2DArray Run this file using the linux commands chmod u+x process2DArray /process2DArray Test that the program works

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

What are the characteristics of a fragmented industry?

Answered: 1 week ago