I need help to change certain values in an Array that I have to a character array.

Here's the code

#include <iostream>
using namespace std;

int main()
{
    char X;
    int nROWS = 4;
    int nCOLUMNS = 4;
    int anArray[4][4] = {{0,1,2,3}, {10,11,12,13}, {20,21,22,23}, {30,31,32,33}};
    string headings[4] = {"LA", "CLT", "SVO", "FR"};
     
    cout << "\t"<<headings[0]<<"\t"<<headings[1]<<"\t"<<headings[2]<<"\t"<<headings[3]<<endl;
    if (anArray[0][0] == 0)
       anArray[0][0] == X;
    cout << headings[0] << "\t" << anArray[0][0] << "\t" << anArray[0][1]<< "\t" << anArray[0][2] << "\t" << anArray[0][3]<<endl;
    
    if (anArray[1][0] == 10)
       cout <<"X";
    if (anArray[1][1] == 11)
       cout << "X";
    cout << "\n" <<headings[1] << "\t" << anArray[1][0] << "\t" << anArray[1][1]<< "\t" << anArray[1][2] << "\t" << anArray[1][3]<<endl;   
    
    if (anArray[2][2] == 22)
       cout << "X";
    cout << "\n" <<headings[2] << "\t" << anArray[2][0] << "\t" << anArray[2][1]<< "\t" << anArray[2][2] << "\t" << anArray[2][3]<<endl;       
    if (anArray[3][3] == 33)
       cout << "X";
    cout << "\n" << headings[3] << "\t" << anArray[3][0] << "\t" << anArray[3][1]<< "\t" << anArray[3][2] << "\t" << anArray[3][3]<<endl;
    
     system("pause");
     return 0;
}

Recommended Answers

All 3 Replies

I don't need int ROWS and int COLUMNS

Member Avatar for jencas

But what is your problem?

Not to sure what your actualy problem is but you are assigning X to [0][0] where X is a char that doesn't have a value and is not initialised. So you assign some random value from your memory into the array. NOT GOOD.

Chris

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.