memcmp

    -1熱度

    1回答

    Memcpy和memcmp函數可以帶一個指針變量嗎? char *p; char* q; memcpy(p,q,10); //will this work? memcmp(p,q,10); //will this work?

    1熱度

    1回答

    我有一個類,其中我在一個特定的成員上過載了==運算符,memcmp()。由於在代碼中完成了錯誤的副本(調用memcpy的尺寸比應該更大),因此調用==運算符時出現段錯誤。 據我所知,UB很神祕,顯然沒有定義,但仍然有一些我注意到的讓我感興趣的東西。 在調試過程中,我將==調用與其實現交換(即a==b與memcmp(a.member_x, b.member_x, SIZE)交換)並且沒有段錯誤! 那

    -3熱度

    2回答

    struct Flat { int a1; int a2; } // a hierarchical struct which containing a struct attribute struct NonFlat { Flat b1; int b2; } Flat f1, f2; memcmp (&f1, &f2, sizeof f1)

    1熱度

    1回答

    我必須在性能敏感的地方比較相等的16字節內存塊。 塊總是完全對齊,它們總是正好是16個字節。在我看來,我應該能夠利用這些知識,並提出比逐字節比較更好的方法。 事實上,我認爲絕大多數memcmp實現都是這樣做的,但顯然這需要一段時間來分析地址和大小。在我的情況不是這樣,但它仍然較快的是: ... mov $0x10,%ecx mov -0x4c(%ebp),%esi repz cmpsb %e

    -1熱度

    1回答

    PInkove部分取自一些SO回答(對不起,我失去了原來的鏈接)。 以下是完整的程序。輸出是false。 using System; using System.Runtime.InteropServices; namespace Memcpy { class Program { [DllImport("msvcrt.dll", CallingConventi

    1熱度

    3回答

    的是否 if(strncmp(buf, buf2, 7) == 0) 做同樣的事情, if(memcmp(buf, buf2, 7) == 0) buf和buf2是的char *數組或相似。 我打算把這個附加到另一個問題上,但後來決定也許最好單獨發佈它。據推測,答案要麼是微不足道的「是」,要麼不是那麼有什麼區別? (我發現來自在線文檔這些功能,但不知道strncmp因爲文檔略有不清楚。)

    -2熱度

    1回答

    我有C++代碼,看起來像這樣: static int* ArrayGenerator() { int temp[1] = {9}; return temp; } static int* ArrayGenerator(int i) { //parameter is just for demonstration int temp[1] = {9};

    -3熱度

    2回答

    #include <stdio.h> #include <stdlib.h> #include <memory.h> #include <string.h> int cauta(const void *x, int n, int dim_el, const void *el) { char *c = (char*) x; int i; for(i = 0

    3熱度

    1回答

    我覺得讀記憶應該不會造成如 char *d=""; char *d2="test"; memcmp(d,d2,10); 什麼問題都memcmp()曾經失敗?

    0熱度

    1回答

    我有一個腳本的入站緩衝區數據,我需要key =>'value'以便我可以對它運行一個數學方程(是的,我知道我需要轉換爲int) 。由於我確定數據是字符串,我試圖對它進行模式匹配。 我看到入站數據,但我從未得到正面匹配。 代碼:從print_f輸出 int getmyData() { char key[] = "total"; char buff[BUFSIZ];