I ran same code linux and HP platform And the result stored was different.
I found that the boundar for comparison is 255.
It can be more undersstood from the below code.

#include <stdio.h>

int main()
{
    FILE *fp=fopen("linux2.txt","wb");
    int a = 100;
    int c=0;
    int i=0;
    for (i=0; i <= 32767; i++)
       {
          c = memcmp(&a,&i,sizeof(int));
                if ( c >0 )
                        fprintf (fp,"Value is -1 when i = %d\n",i);
             }
    fclose(fp);
    return 0;
}

The answer stored in Linux and HP was different.
In HP the text file created had only first 99 numbers but on linux it was 0-99 then 256-355 and so on.

Anyone have any idea about limitation of memcmp function.

Recommended Answers

All 2 Replies

So am I to assume that you completely ignored the replies from your other thread that asks essentially the same question?

Deceptikon, By the time i got answer from 2nd thread i had already posted this....
Anyways Thanks for your answer..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.