Click here to Skip to main content
15,904,023 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to write a existing bigger binary file into small/compact binary file in C. Pin
rp_suman22-Oct-10 1:04
rp_suman22-Oct-10 1:04 
QuestionError : can not open file "hid.lib" Pin
Ruchira Patel21-Oct-10 18:56
Ruchira Patel21-Oct-10 18:56 
AnswerRe: Error : can not open file "hid.lib" Pin
rp_suman21-Oct-10 19:44
rp_suman21-Oct-10 19:44 
GeneralRe: Error : can not open file "hid.lib" Pin
Cedric Moonen21-Oct-10 20:27
Cedric Moonen21-Oct-10 20:27 
GeneralRe: Error : can not open file "hid.lib" Pin
rp_suman22-Oct-10 0:46
rp_suman22-Oct-10 0:46 
AnswerRe: Error : can not open file "hid.lib" Pin
Cedric Moonen21-Oct-10 20:25
Cedric Moonen21-Oct-10 20:25 
AnswerRe: Error : can not open file "hid.lib" Pin
David Crow22-Oct-10 3:01
David Crow22-Oct-10 3:01 
QuestionAuto Update My Application... Pin
loid grey manuel21-Oct-10 17:35
loid grey manuel21-Oct-10 17:35 
AnswerRe: Auto Update My Application... Pin
Moak22-Oct-10 0:07
Moak22-Oct-10 0:07 
GeneralRe: Auto Update My Application... Pin
loid grey manuel25-Oct-10 14:41
loid grey manuel25-Oct-10 14:41 
QuestionLoading a Registry Hive with RegLoadKey() Pin
Richard Andrew x6421-Oct-10 14:41
professionalRichard Andrew x6421-Oct-10 14:41 
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 
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 
No it will crash, but Smile | :)
char *OPTIONS_ENUMS[5] = {"OPT_1","OPT_2","OPT_3","OPT_4"}; // This works
for(int j = 0; j < 100; j++)
{   
    if(OPTIONS_ENUMS[j] == NULL)     
    return j;
}


EDIT:
As Richard says in next post this may be error prone and is more a joke than a solution.

With C++0x (gcc 4.5 only for now) we can use the standard collections with initializer lists like:
std::vector<LPCSTR> OPTIONS_ENUMS = {"OPT_1","OPT_2","OPT_3","OPT_4"};

When not available (MS compilers for now) we must stay in C world and use a macro:
#define ARRAY_SIZE(_Array) (sizeof(_Array) / sizeof(_Array[0])) // This is the answer 

char *OPTIONS_ENUMS[] = {"OPT_1","OPT_2","OPT_3","OPT_4"}; 
for (j = 0; j < ARRAY_SIZE(OPTIONS_ENUMS); j++)
{   
    if(OPTIONS_ENUMS[j] == NULL) // will never happen   
    return j;

    // do something with OPTIONS_ENUMS[j]
}


cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
modified on Thursday, October 21, 2010 6:50 PM

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.