Click here to Skip to main content
15,891,749 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Passing a char array to a routine Pin
Richard MacCutchan21-Oct-10 11:16
mveRichard MacCutchan21-Oct-10 11:16 
GeneralRe: Passing a char array to a routine Pin
Garth J Lancaster21-Oct-10 11:25
professionalGarth J Lancaster21-Oct-10 11:25 
GeneralRe: Passing a char array to a routine Pin
Richard MacCutchan21-Oct-10 11:59
mveRichard MacCutchan21-Oct-10 11:59 
GeneralRe: Passing a char array to a routine [modified] Pin
Alain Rist21-Oct-10 11:34
Alain Rist21-Oct-10 11:34 
GeneralRe: Passing a char array to a routine Pin
Richard MacCutchan21-Oct-10 11:59
mveRichard MacCutchan21-Oct-10 11:59 
GeneralRe: Passing a char array to a routine Pin
Alain Rist21-Oct-10 12:37
Alain Rist21-Oct-10 12:37 
GeneralRe: Passing a char array to a routine Pin
Andy20222-Oct-10 2:03
Andy20222-Oct-10 2:03 
AnswerRe: Passing a char array to a routine Pin
Alain Rist22-Oct-10 4:05
Alain Rist22-Oct-10 4:05 
Andy202 wrote:
Thanks I just tested this and it did not work. The size is always 1.

Have I implemented it correct?


Nope Smile | :)

Use it as follows:
#define ARRAY_SIZE(_Array) (sizeof(_Array) / sizeof(_Array[0])) // This is the answer

char *OPTIONS1_ENUMS[] = {"OPT_1", "OPT_2", "OPT_3", "OPT_4"};
char *OPTIONS2_ENUMS[] = {"OPT_1", "OPT_4"};
char *OPTIONS3_ENUMS[] = {"OPT_1234"}; 

void GetOptions(short enumValue, char** szOptions, int Size)
{	
	printf("Array Size = %d\n", Size);    
}
int main()
{
	// In the Main program call GetOptions() for 3 different sized arrays
	GetOptions(1, OPTIONS1_ENUMS, ARRAY_SIZE(OPTIONS1_ENUMS));
	GetOptions(2, OPTIONS2_ENUMS, ARRAY_SIZE(OPTIONS2_ENUMS));
	GetOptions(3, OPTIONS3_ENUMS, ARRAY_SIZE(OPTIONS3_ENUMS));
}

BTW you should not call your arrays OPTIONSx_ENUMS:
- as capitalized names are conventionnally reserved for C macros, and
- they are not enums but C arrays of const char*.
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)

GeneralRe: Passing a char array to a routine Pin
Code-o-mat21-Oct-10 21:40
Code-o-mat21-Oct-10 21:40 
AnswerRe: Passing a char array to a routine Pin
Aescleal21-Oct-10 21:31
Aescleal21-Oct-10 21:31 
Generalis there something faster than GetPixel and SetPixel ? [moved] Pin
inayathussaintoori21-Oct-10 8:38
inayathussaintoori21-Oct-10 8:38 
GeneralRe: is there something faster than GetPixel and SetPixel ? [moved] Pin
Code-o-mat21-Oct-10 9:19
Code-o-mat21-Oct-10 9:19 
GeneralRe: is there something faster than GetPixel and SetPixel ? [moved] Pin
Sauro Viti21-Oct-10 21:20
professionalSauro Viti21-Oct-10 21:20 
GeneralRe: is there something faster than GetPixel and SetPixel ? [moved] Pin
inayathussaintoori22-Oct-10 1:20
inayathussaintoori22-Oct-10 1:20 
GeneralRe: is there something faster than GetPixel and SetPixel ? [moved] Pin
inayathussaintoori22-Oct-10 1:32
inayathussaintoori22-Oct-10 1:32 
GeneralRe: is there something faster than GetPixel and SetPixel ? [moved] Pin
Sauro Viti22-Oct-10 1:41
professionalSauro Viti22-Oct-10 1:41 
Questiongetting pixel color values by GetDiBit function Pin
inayathussaintoori21-Oct-10 2:01
inayathussaintoori21-Oct-10 2:01 
AnswerRe: getting pixel color values by GetDiBit function Pin
Sauro Viti21-Oct-10 2:18
professionalSauro Viti21-Oct-10 2:18 
GeneralRe: getting pixel color values by GetDiBit function Pin
inayathussaintoori21-Oct-10 2:32
inayathussaintoori21-Oct-10 2:32 
GeneralRe: getting pixel color values by GetDiBit function Pin
Sauro Viti21-Oct-10 2:50
professionalSauro Viti21-Oct-10 2:50 
AnswerRe: getting pixel color values by GetDiBit function Pin
GAJERA21-Oct-10 2:57
GAJERA21-Oct-10 2:57 
QuestionOverlap A Bitmap using DeviceContext Pin
002comp21-Oct-10 0:38
002comp21-Oct-10 0:38 
AnswerRe: Overlap A Bitmap using DeviceContext Pin
GAJERA21-Oct-10 1:05
GAJERA21-Oct-10 1:05 
GeneralRe: Overlap A Bitmap using DeviceContext Pin
Sauro Viti21-Oct-10 1:11
professionalSauro Viti21-Oct-10 1:11 
GeneralRe: Overlap A Bitmap using DeviceContext Pin
GAJERA21-Oct-10 1:18
GAJERA21-Oct-10 1:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.