So I am almost finished with this program, and I need to take a set of int values from a previous array, go through each value, determine if the value is >= 128, and if it is then display and astrix ("*"), and if its not display an empty space (" ").
How do I store character values into an array? (Look towards the bottom of my code).
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cmath>
usingnamespace std;
constint rows = 4,
cols = 4;
void displayArray(int a[rows][cols]);
int main()
{
int intImage[rows][cols],
rc[rows][cols],
i,
j;
char charImage[rows][cols];
ifstream infile;
infile.open("TextFile1.txt"); //Importing TExtFile1.txt
if (!infile) //Checks whether or not the program can locate the file or not
{
cerr << "file could not be found\n"; //Displays an error message
exit(1); //Ends the program
}
cout << "The image before the Roberts Cross operator has been applied to it" << endl;
cout << endl;
for (i = 0; i < rows; i++)
{
for (j = 0; j < cols; j++)
{
infile >> intImage[i][j];
}
}
displayArray(intImage);
cout << endl;
cout << "The image after the Roberts Cross operator has been applied to it" << endl;
cout << endl;
for (i = 0; i < rows; i++)
{
for (j = 0; j < cols; j++)
{
rc[i][j] = (abs(intImage[i][j] - intImage[i + 1][j + 1]) , abs(intImage[i + 1][j] - intImage[i][j + 1]) );
}
}
displayArray(rc);
for (i = 0; i < rows; i++)
{
for (j = 0; j < cols; j++)
{
if (rc[i][j] >= 128)
charImage[i][j] = "*";
elseif (rc[i][j] < 128)
charImage[i][j] = " ";
}
}
return 0;
}
void displayArray(int a[rows][cols])
{
int i,
j;
for (i = 0; i < rows; i++)
{
for (j = 0; j < cols; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
}