|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
||||
|
||||
|
Borland doesn't like an empty array matrix?
Borland C++ doesn't like when I define an array like this:
char test[]; For some reason a number always needs to be in the []..why is that? -andy
__________________
hmmm... |
|
#2
|
|||
|
|||
|
You are defining an array for which space will be allocated. The compiler needs to know how much space to allocate. You can use the [] in a declaration, but not in a definition.
|
|
#3
|
||||
|
||||
|
As 3dfxMM points out, you need to tell the compiler how big the array will be so that it can allocate enough memory to it. There are a couple ways to do that:
1. Do it explicitly; e.g.: char test[10]; 2. Do it implicitly with an initialization string or array; e.g.: char test[] = "Just do it like this"; int itest[] = {0,1,2,3,4,5,6,7,8,9} If you really and honestly and truly don't want to or cannot specify its size at compile time, then use the alternative syntax and declare it as a pointer and allocate it dynamically at runtime; e.g.: char *test; |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Borland doesn't like an empty array matrix? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|