Click here to Skip to main content
14,327,936 members

C / C++ / MFC

 
GeneralRe: error C2143 error C2059 Pin
_Flaviu31-Jul-19 3:27
member_Flaviu31-Jul-19 3:27 
GeneralRe: error C2143 error C2059 Pin
Richard MacCutchan31-Jul-19 4:03
protectorRichard MacCutchan31-Jul-19 4:03 
GeneralRe: error C2143 error C2059 Pin
_Flaviu31-Jul-19 22:01
member_Flaviu31-Jul-19 22:01 
GeneralRe: error C2143 error C2059 Pin
k505431-Jul-19 5:39
memberk505431-Jul-19 5:39 
GeneralRe: error C2143 error C2059 Pin
_Flaviu31-Jul-19 21:06
member_Flaviu31-Jul-19 21:06 
QuestionRe: error C2143 error C2059 Pin
David Crow1-Aug-19 3:22
memberDavid Crow1-Aug-19 3:22 
AnswerRe: error C2143 error C2059 Pin
k50541-Aug-19 4:28
memberk50541-Aug-19 4:28 
GeneralRe: error C2143 error C2059 Pin
k50541-Aug-19 3:57
memberk50541-Aug-19 3:57 
The only way I know is to compare member by member:
struct foo {
   short s;
   double d;
   char str[24];
};

int compare_foo(const struct foo *f1, const struct foo *f2)
{
    int retval;

    if( (retval =  f1->s - f2->s) != 0)
        return retval;

    if( (retval = f1->d - f2->d) != 0)
         return retval;

    return strcmp(f1->str, f2->str);
}
Note that this demonstrates another reason that you should avoid memcmp() on structs: if the struct in question contains strings, the portions of the string after the terminating null byte may not be equal, so strcmp(str1,str2) might not return the same value as memcmp(str1, str2, sizeof str1). You could, use memcmp(str1, str2, strlen(s1)+1): the extra byte accounting for the terminating null byte, so that you do not get a false equal on e.g. "help" and "helper". But that's a silly way to compare strings: you effectively run through str1 twice, once to get its length, then again to do the comparison, assuming str1 is equal to, or an initial substring of, str2. Use strcmp() to compare strings, or strcasecmp() or strcoll() when appropriate.

modified 1-Aug-19 10:35am.

GeneralRe: error C2143 error C2059 Pin
Richard MacCutchan31-Jul-19 21:32
protectorRichard MacCutchan31-Jul-19 21:32 
GeneralRe: error C2143 error C2059 Pin
Peter_in_27801-Aug-19 0:53
professionalPeter_in_27801-Aug-19 0:53 
GeneralRe: error C2143 error C2059 Pin
Richard MacCutchan1-Aug-19 1:31
protectorRichard MacCutchan1-Aug-19 1:31 
QuestionBest way to call REST Service from C++ Pin
ptr_Electron24-Jul-19 22:50
memberptr_Electron24-Jul-19 22:50 
AnswerRe: Best way to call REST Service from C++ Pin
Gerry Schmitz25-Jul-19 2:49
mveGerry Schmitz25-Jul-19 2:49 
QuestionRe: Best way to call REST Service from C++ Pin
Richard MacCutchan25-Jul-19 3:52
protectorRichard MacCutchan25-Jul-19 3:52 
AnswerRe: Best way to call REST Service from C++ Pin
Gerry Schmitz25-Jul-19 10:13
mveGerry Schmitz25-Jul-19 10:13 
GeneralRe: Best way to call REST Service from C++ Pin
Richard MacCutchan25-Jul-19 22:31
protectorRichard MacCutchan25-Jul-19 22:31 
GeneralRe: Best way to call REST Service from C++ Pin
Gerry Schmitz25-Jul-19 22:48
mveGerry Schmitz25-Jul-19 22:48 
GeneralRe: Best way to call REST Service from C++ Pin
Richard MacCutchan25-Jul-19 23:29
protectorRichard MacCutchan25-Jul-19 23:29 
GeneralRe: Best way to call REST Service from C++ Pin
Gerry Schmitz26-Jul-19 5:12
mveGerry Schmitz26-Jul-19 5:12 
QuestionCall C functions from VC++ Pin
_Flaviu17-Jul-19 22:20
member_Flaviu17-Jul-19 22:20 
AnswerRe: Call C functions from VC++ Pin
phil.o17-Jul-19 23:19
mvephil.o17-Jul-19 23:19 
GeneralRe: Call C functions from VC++ Pin
_Flaviu18-Jul-19 0:19
member_Flaviu18-Jul-19 0:19 
GeneralRe: Call C functions from VC++ Pin
phil.o18-Jul-19 0:25
mvephil.o18-Jul-19 0:25 
AnswerRe: Call C functions from VC++ Pin
Richard MacCutchan18-Jul-19 0:36
protectorRichard MacCutchan18-Jul-19 0:36 
GeneralRe: Call C functions from VC++ Pin
_Flaviu18-Jul-19 2:57
member_Flaviu18-Jul-19 2:57 

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.