Assorted questions

1: How do you define multi-dimensional arrays? I thought it was like this:
1
2
3
int array[3][3]={1,2,3}
                {4,5,6}
                {7,8,9};

but that gives me an error where it says it needs a semicolon before the next braces.

2. How do you clear the screen without using system()?

3. Is it possible to get Windows message boxes into a console application if I include windows.h?

4. What are the ASCII values for the different arrow keys? Or if you could give me a link to a place where I could find all of them, I would appreciate it. (or if I can operate with windows and use the message loop, please tell me.)

5. If I am including .cpp files in a main project and not actually compiling them as stand-alone programs, do I need them to have a main() function?

Thanks in advance.
Last edited on
1)
1
2
3
4
5
int array[3][3] = {
{1,2,3},
{4,5,6},
{7,8,9}
};


2)http://www.cplusplus.com/articles/4z18T05o/

3)Not sure what you mean.

4)I think it's different depending on your OS.

5)Only one main() function per program.
3) I mean that I am compiling a console application, and I want it to have message boxes that pop up when the user left clicks, right clicks, or breaks the program's rules. The program I am writing really needs to be a console app, though, because the number of renders that would be required would murder my poor netbook.

3) I mean that I am compiling a console application, and I want it to have message boxes that pop up when the user left clicks, right clicks, or breaks the program's rules. The program I am writing really needs to be a console app, though, because the number of renders that would be required would murder my poor netbook.

as far as i know (and as far as i understand your question), yes. simply use the windows.h header, and you can use MessageBox()
3) Yes.
4) There is no ASCII value, but they have keycodes:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx

This should be in the "Windows programming" subforum.
Last edited on
This is not a Windows program, despite the use of windows.h

Thanks for your help.
1) You have to separate the numbers enclosed in {}s using ","s too:
1
2
3
4
5
int Example[3][3]={
    {3,1,2},
    {8,7,9},
    {6,5,4},
}


2) The most simple ways are clrscr() from conio.h, and the standard system("cls") (wich is bad, but i still use it because clrscr does'nt works for me...).

3)What chipp said before, MessageBox().

4)For Windows:
Up arrow key: 72
Down arrow key: 80
Right arrow key: 77
Left arrow key: 75
Enter key: 13
Backspace key: 8

5)A program can only have 1 main function.
This is not a Windows program, despite the use of windows.h

Bit of a contradiction, isn't it? Unless you're using something like winelib (and even then it would belong into Windows programming).

@samrux:
The values you listed for the arrow keys are letters, both for ASCII and keycodes.
Last edited on
Well, for me it works perfectly when using getch()
Topic archived. No new replies allowed.