memcpy

    0熱度

    1回答

    我正在學習使用C(linux)中的共享內存進行編程。我需要在幾個使用fork()創建的進程之間共享一些結構。不幸的是,當我試圖初始化新共享地址空間時,我在memcpy調用中遇到了一個很小的錯誤(控制檯中沒有輸出)。 #include <stdio.h> #include <stdlib.h> #include <limits.h> #include <sys/stat.h> #includ

    1熱度

    1回答

    如果我想在調用回調函數時存儲查詢返回的信息,是否應該對argv中的每個參數進行深層複製,或者我可以安全地假定sqlite3在從回調返回後不會釋放它?我使用C作爲編程語言。 static int callback_consult(void *dummy, int argc, char **argv, char **col_name) { res_consult_t * answer = &

    0熱度

    3回答

    我想分割我的32位字符數組在2 16位數組,但它給出超過16位奇怪的輸出。任何幫助。 #include <stdio.h> #include <string.h> #include "hexb.h" #include "flr.h" int main() { int i,j,k; char inbit[20]; char fdata[31],coeff[15],s

    0熱度

    1回答

    typedef struct { int M; int N; int records[NMAX][SZM]; int times[NMAX]; bool prime[NMAX]; } DATASET; typedef int ITEMSET[SZM]; __device__ DATASET d_db; DATASET

    5熱度

    3回答

    我有std :: string變量。我需要從無符號字符數組中放入一些字節。我知道第一個字節和第一個字母。 我可以使用std :: string :: assign函數。我已經完成了。 但我想用正確的方式使用memcpy函數解決該問題。 std::string newString; memcpy(&newString, &bytes[startIndex], length); 我知道這是錯誤的

    1熱度

    1回答

    在d語言,等同什麼是下面的語句 假設代碼: - int size = 8; int shift = 1; int[size] skip; int[size] suff; memcpy(&skip[0], &skip[0]+shift, (m-shift)*(int.sizeof)); memset(&skip[0]+(m-shift),0, shift*(int.sizeof))

    -6熱度

    5回答

    正在關注another question which caused much confusion,這裏是關於指針語義的問題,希望能夠解決這些問題: 這個程序是否在所有情況下都有效?唯一有趣的部分是在「pa1 == pb」分支。 #include <stdio.h> #include <string.h> int main() { int a[1] = { 0 }, *pa1 = &

    0熱度

    1回答

    作爲實現編譯器的類項目的一部分,我還實現了用作編譯器符號表的哈希表。 散列表的實現目的是非常低級的,手動打包的原始內存塊,它僅用於存儲令牌對象。因此,爲了優化哈希表的可序列化性,我決定簡單地將表中的令牌內聯,也就是說,當第一次插入令牌時,只需將令牌對象memcpy複製到表的內存中即可。 我知道一個不應該memcpy a class that has virtual functions or poi

    0熱度

    1回答

    #include <stdio.h> #include <stdlib.h> #include <string.h> void swap (void *vp1, void *vp2, const size_t size) { char *buffer = (char *)malloc(sizeof(char)*size); memcpy(buffer, vp1, siz

    0熱度

    1回答

    我有兩個陣列,a和b,兩個長度的x字節。我需要使用memcpy複製內存從a到b。什麼是正確的語法使用,因爲memcpy接受兩個void*作爲它的參數?它是: memcpy(&a[0], &b[0], x);