Start New Discussion within our Software Development Community

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);
    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.

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

This question has already been answered. Start a new discussion instead.