#2d array problem

15 messages · Page 1 of 1 (latest)

gleaming sage
#

I want to use char x[N][N]= all N*N terms = 'X'
how can I do this
thank you

last prawnBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

gleaming sage
#

I can only use for loop to fill in the item?

west notch
#

memset(array, 'X', sizeof(array));
Or

#
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            a[i][j] = 'X';
        }
    }
cerulean stirrup
#

(we try to not just give the solution)

#

but yes - loop, memset, or some std:: options

gleaming sage
cerulean stirrup
#

great 🙂

gleaming sage
#

I want to do let the C++ know
a is same as A
my previous method is

char x;
cin>> x
if (x=='a' or x=='A') return true

do you have smarter method
I design to do this by using the table
by char x+32

#

then I dont need to do if (x=='a' or x=='A') until if (x=='z' or x=='Z')

#

however
can I do something like this?

cerulean stirrup
#

@gleaming sage x=='a' or x=='A' is perfectly fine. You could to tolower(x) == 'a' if you want, but really either are fine.

cerulean stirrup
last prawnBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.