memcpy

    2熱度

    6回答

    我正在查看一些C++代碼,並且遇到了這個memcpy函數。我瞭解memcpy的作用,但是他們向源添加了一個int。我試圖查找memcpy的源代碼,但我似乎無法理解添加實際上對memcpy函數做了什麼。 memcpy(Destination, SourceData + intSize, SourceDataSize); 換句話說,我想知道SourceData + intSize在幹什麼。 (我想

    -1熱度

    7回答

    哪兩個更快:? 1. char* _pos ..; short value = ..; *((short*)_pos = va; 2. char* _pos ..; short value = ..; memcpy(_pos, &value, sizeof(short));

    1熱度

    2回答

    我正在用C++中的指針和緩衝區回顧我的技能。我試了下面的代碼,一切正常。沒有泄漏,沒有碰撞,沒有。 說實話我沒有想到這一點。 當我打電話char* buf2 = new char[strlen(buf)]我沒有想到srlen(buf)返回正確的大小。我一直認爲strlen 需要一個NULL終止的字符串工作。在這裏,情況並非如此,爲什麼它使用這個代碼? int main(){ con

    1熱度

    3回答

    我想複製一個對象並通過網絡使用winsock發送它,但有一個問題。如果我將一個對象複製到堆上的字符數組中,我會銷燬堆棧。這裏是我的代碼: testclass backditup; //This is an object with information testclass restorenaarhier; //I will copy it to this object backditup.

    0熱度

    2回答

    嗯,我必須恢復一個在此之前回答過的問題。由於其他原因我做了一些更改,現在我又遇到了問題。下面是相關的細節: volatile char RxBuffer1[NEMA_BUFFER_LENGTH]; uint32_t NEMA_TypeStart; char NEMA_Type[10]; uint32_t len; ... memcpy(NEMA_Type,(const char*)Rx

    0熱度

    2回答

    我正在使用CUDA編寫的程序出現問題。我有一個輸入數組和輸出數組,我需要將其複製到設備內存。問題在於兩個陣列太大而無法放入設備內存。我現在正在做的是拆分輸入和輸出數組,併爲這兩個部分按順序運行內核。 爲了使這種方法起作用,我使用了一箇中間數組,因爲cudaMemcpyFromArray和cudaMemcpyToArray只能用於紋理內存。這會導致不必要的內存複製操作。有誰知道更有效的方法?

    5熱度

    1回答

    當我創建使用本徵矩陣,如下所示: Eigen::MatrixXd M(3,3); M<< 1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0 ; std::cout<<M<<std::endl; 產生 1 4 7 2 5 8 3 6 9 我可以通過數據的指針行走,打印每個元素: double * d = M.data();

    1熱度

    2回答

    // Works int fnamesize=0; fnamesize=message[0]<<24; fnamesize+=message[1]<<16; fnamesize+=message[2]<<8; fnamesize+=message[3]; // Doesn't work int fsize; memc

    1熱度

    1回答

    的代碼是:(我已經打上了故障線路與評論) #include <stdio.h> #include <stdlib.h> #include <string.h> #include <conio.h> typedef struct stack_node_type{ int *nr; char *string; struct stack_node_type *next;

    0熱度

    1回答

    我想將數據複製到一個全局結構內的結構數組中的無符號字符緩衝區,但它在某種程度上失敗。這是我的: #define MAX_FILES 12 #define SIZE 512 typedef struct bufDataType { unsigned char buf[SIZE]; } bufData; static struct { int counter;