realloc

    3熱度

    4回答

    我正在研究一個相當舊的軟件包(NWChem)的模塊,我不確定如何從一個相當常用的函數調用中創建函數的最佳方法。主包中有一組用於處理運行時數據庫的函數。我經常一起使用的一對是rtdb_get_info和rtdb_get,以獲取有關數據庫中某個值的內容的信息並獲取實際值。這些函數的標題是: extern int rtdb_get_info(const int, const char *, int *,

    -2熱度

    2回答

    這是整天編輯我的代碼,但無法找到我的數組的最後一個位置被覆蓋的原因! #include <stdio.h> #include <math.h> #include <ctype.h> #include <string.h> #include <stdlib.h> typedef struct Person{ char *name; char *surname;

    1熱度

    3回答

    我需要實現一個簡單的指向一個typedef指針的動態指針數組。 每次用戶請求時使用realloc,數組的大小將按sizeof(指針)增長。 所以我有是這樣的: #include <stdio.h> #include <string.h> #include <stdlib.h> typedef void* node; void printmem(node* a, int c) {

    3熱度

    3回答

    我的問題是關於'realloc'。 下面的代碼工作正常(無警告): #include <stdio.h> #include <stdlib.h> int main() { int num=10; int *vet; int i; for (i=0; i<num; i++) { /* allocate memory of ve

    -1熱度

    1回答

    使用valgrind和realloc有什麼問題嗎?看來valgrind給了我關於記憶的錯誤,即它沒有被釋放,儘管我相信我釋放了它應該被釋放的一切,你能幫助我嗎? /* declarations*/ typedef struct Hash_node{ char* word; char** overflow_list; int overlow; } Hash_no

    3熱度

    3回答

    當我在VS2013中運行此代碼時,它失敗說「realloc test.exe已觸發了一個斷點。」我不知道爲什麼,任何想法(不過,如果我嘗試realloc的小值這將是確定) #include<stdlib.h> #include <limits.h> int main() { char *big = malloc(100); char *c; //c = mall

    4熱度

    2回答

    原來的問題 我可以使用realloc()功能如下面的代碼: int *ptr, i, num=5; for (i=0; i<num; i++) void *nptr = realloc (ptr, (i+1) * sizeof(int));

    2熱度

    2回答

    #include <stdio.h> #include <stdlib.h> int main (int argc, char * argv []) { int alloc = 10; int i = 0; int *array = (int *) malloc (alloc * sizeof(*array)); printf("Enter some

    1熱度

    4回答

    我有下面的代碼: #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char ** argv) { //just checking to see where the stack printf("The stack is around %p\n", &argc);

    12熱度

    3回答

    realloc如何在後臺工作? 如果沒有足夠的可用內存在老地方做 這一分配二/許多內存塊和一個指針 指向的是和其他在內部,每個 其他或複製到新的地方老區域鏈接哪裏夠 內存是否可用並且指針正在更新爲新地址並刪除舊內存? 而且是realloc是編譯器/操作系統相關或獨立?