insert symbol in an array>??

Jan 6, 2012 at 1:03pm
may i know is it possible for me to insert this "□" symbol in an array??
actually i was doing an airlines seat reservation system, and normally people will do as follow:
------------------------
char seat[??][??];
for( int r=0; r<??; ++r )
for( int c=0; c<??; ++c )
{
seat[r][c] = 'O';
}

so the output will be something like this,

O O O O O O O O O
O O O O O O
O O O O O O O O O O

O O O O O O O O O O
O O O O O O
O O O O O O O O O

but what i want is

□ □ □ □ □ □ □ □ □
□ □ □ □ □ □
□ □ □ □ □ □ □ □ □ □

□ □ □ □ □ □ □ □ □ □
□ □ □ □ □ □
□ □ □ □ □ □ □ □ □

how to do this?as this is not char??
Jan 6, 2012 at 1:12pm
if □ can be represented by a single char depends on the encoding you are using. In ASCII it's not possible. It might be possible if you use std::string instead of a single char but that also depends on the encoding.
Last edited on Jan 6, 2012 at 1:13pm
Jan 6, 2012 at 1:16pm
When using the console, you're restricted to one character set. First half is ASCII, the second half may vary. It is probably going to be http://en.wikipedia.org/wiki/Code_page_437
How about 254?
Jan 6, 2012 at 4:57pm
Just like that

1
2
3
4
wchar_t seat[R][C];
for( int r=0; r<R; ++r )
    for( int c=0; c<C; ++c )
        seat[r][c] = L'□';

full demo with console output : http://ideone.com/SCxNn
(tested using Visual Studio 2010 on Windows and using gcc on Linux. Neither is restricted to ASCII)

Last edited on Jan 6, 2012 at 4:58pm
Topic archived. No new replies allowed.