Click here to Skip to main content
15,895,709 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Loading a Registry Hive with RegLoadKey() Pin
David Crow21-Oct-10 14:54
David Crow21-Oct-10 14:54 
GeneralRe: Loading a Registry Hive with RegLoadKey() Pin
Richard Andrew x6421-Oct-10 14:58
professionalRichard Andrew x6421-Oct-10 14:58 
QuestionMinGW dependancies Pin
James_72221-Oct-10 10:41
James_72221-Oct-10 10:41 
AnswerRe: MinGW dependancies Pin
Aescleal21-Oct-10 21:36
Aescleal21-Oct-10 21:36 
QuestionHow to find the positions of '\n' within a string object [modified] Pin
sadas232341s21-Oct-10 9:21
sadas232341s21-Oct-10 9:21 
AnswerRe: How to find the positions of '\n' within a string object [Modified] Pin
Code-o-mat21-Oct-10 9:30
Code-o-mat21-Oct-10 9:30 
AnswerRe: How to find the positions of '\n' within a string object Pin
Alain Rist21-Oct-10 11:48
Alain Rist21-Oct-10 11:48 
QuestionPassing a char array to a routine Pin
Andy20221-Oct-10 8:43
Andy20221-Oct-10 8:43 
I need to pass an array into a procedure and return a string. The problem is the array could be 1, 2, 3 or 4 character strings.

I am stuck as how to do it, see typical arrays below.

char *OPTIONS_ENUMS[4] = {
			"OPT_1",
			"OPT_2",
			"OPT_3",
			"OPT_4"};

			
char *OPTIONS2_ENUMS[4] = {
			"OPT_1",
			"OPT_4"};
		
			
char* GetOptions(short nStatus, char* szOptions)
{
	int i, nOptions;
	// How can I tell how many elements in the array?
	nOptions = sizeof(ssmStatusOptions);	// This will not work
	for(i=0; i < nOptions; i++)
	{
		if(nStatus == 0)
		{
			if(strcmp(szOptions[i], "NULL") == 0)
			{
				return "NULL";
			}
			else if(strcmp(szOptions[i], "ITEM1") == 0)
			{
				return "ITEM1";
			}
			else if(strcmp(szOptions[i], "NO_DATA") == 0)
			{
				return "NO_DATA";
			}
		}
		else if(nStatus == 1)
		{
			if(strcmp(szOptions[i], "OK") == 0)
			{
				return "OK";
			}
			else if(strcmp(szOptions[i], "ITEM2") == 0)
			{
				return "ITEM2";
			}
			else if(strcmp(szOptions[i], "NO_DATA") == 0)
			{
				return "NO_DATA";
			}
		}
	}
}
How to call the procedure

e.g.
GetOptions(1, OPTIONS2_ENUMS);

where OPTIONS2_ENUMS is

char *OPTIONS_ENUMS[4] = {
        "OPT_1",
        "OPT_2",
        "OPT_3",
        "OPT_4"};


I need to know how many elements in the array and how to pass over the array. Its a c code project.

Many thanks.
AnswerRe: Passing a char array to a routine Pin
Code-o-mat21-Oct-10 9:27
Code-o-mat21-Oct-10 9:27 
GeneralRe: Passing a char array to a routine Pin
Andy20221-Oct-10 10:53
Andy20221-Oct-10 10:53 
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 
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 

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.