[QUOTE="Barry Schwarz"]\n[QUOTE]\n[QUOTE="qak"]\nEquivalent to assemply:\n cmp [esi], 'Test'\nIn C:\n // slow and long\n if(p == 'T' && p == 'e' && p == 's' && p == 't')...\n // have to look up Ascii table, hard to change\n if (*(int*)p == 0x54657374)...\nPlease have a better solution, thanks.[/QUOTE]\n\nI'd second memcmp. Try it and measure the speed (not of the test -\-\nthat will be quite hard and not very informative -\- but of your\nprogram). A lot of maintainable C code has been sacrificed on the alter\nof efficiency.\n\nIf you still want to avoid the standard idiom (memcmp) then you can\navoid the gruesome constant simply by using a string literal:\n\nif (*(int32_t *)p == *(int32_t *)"Test") ...\n\nUsing int32_t makes the intent a little clearer.[/QUOTE]\n\nHow do you insure that the value of p and the address of the\nstring literal are suitably aligned for int. If either is not,\nthe statement invokes undefined behavior.[/QUOTE]\n\nActually both sides are undefined behavior regardless of\nalignment, because effective type conditions are not met.