Daniel Rogers

Pointer problems

Discussion created by Daniel Rogers on Nov 27, 2006
Latest reply on Nov 29, 2006 by CompilerGuru
I have used the ICC compiler in the past and are changing my code over into CW.
 
One line I are haveing trouble with it is one I use all the time.
 
I have a string decleared
 
#define S_TABLANE      "LANE\0"
#define S_TABOUTLET    "OUTLET\0"
#define S_TABSIZE      "SIZE\0"
#define S_TABAVGSIZE   "PACKS\0"
I then have an array that points to each of these strings.
 
const char* TabName[] = {S_TABLANE,S_TABOUTLET,S_TABSIZE,S_TABAVGSIZE};
in my old code I accessed this by doing this
 
gputs(TabName[cTab]);
 
That would display the required string this on longer is the case. The screen displays rubish and it is in a never ending loop. Never finds the end of the string.
 
To get round it I did a switch case statement which works
 
   switch (cTab) {
     case 0:
       gputs(S_TABLANE);
       break;
     case 1:
       gputs(S_TABOUTLET);
       break;
     case 2:
       gputs(S_TABSIZE);
       break;
     case 3:
       gputs(S_TABAVGSIZE);
       break;
   }
why does CW not like my pointer array.
 

 

Outcomes