realloc

    -1熱度

    1回答

    這個函數是什麼錯誤,這是預計將一個行和一列添加到給定的二維數組?矩陣是對稱的。 void updateMatrix(double ***mat, int size, double *vec) { // mat is sizeXsize matrix, length of vec is size+1 *mat = (double**)realloc(*mat, (size + 1)*si

    0熱度

    2回答

    好的,所以我正在讀取一個txt文件,並將每個項目按新行存儲到一個字符串數組中。唯一的問題是,我需要在接近填滿時將此數組的大小調整爲5。 輸入看起來像這樣,除了很多大 CSE 1104 CSE 1105 CSE 1310 CSE 2320 IE 2308 PHYS 1443 MATH 1426 這裏是我的代碼 void printFileError(char *s) { p

    0熱度

    3回答

    *MyFile.h* typedef char* dado_t; typedef struct elemento elemento; typedef struct lista2 lista2; *MyFile.c* struct elemento{ dado_t str; elemento* ant;

    0熱度

    2回答

    我試圖動態分配一個結構數組,但是每當我運行程序時,我不斷得到:a.out(6487,0x7fff7ecb8300)malloc:*對象0x7fff6f670000錯誤:指針爲realloc'沒有被分配d *設置malloc_error_break斷點調試 struct node { char course[25]; char category[20]; char pr

    1熱度

    1回答

    我在此示例代碼來說明我的問題: /** * begin end * v v * XXXXXXXXXXXXXXXX *^ * data * [===========] size * [==============] capacity */ typedef struct list_t { int *data; int *begin; int *en

    1熱度

    3回答

    我有以下的功能,我已經在C程序很多次,使用前: /** Splits a given string into an array of strings using given delimiters. @param input_string The string to be split. @param delimiters The characte

    0熱度

    1回答

    目前我的代碼使用堆棧,並將用戶輸入的字符串逐個推入堆棧。不過,我想使它動態的,我會malloc/realloc,我知道我錯過了一些完全明顯的東西,但我想我有隧道視野...幫助? #include <stdio.h> #include <stdlib.h> #define MAXSIZE 100 char a [MAXSIZE]; char * p = a; int top = -1;

    -1熱度

    1回答

    我有一個動態分配的結構數組。我正在寫一個函數,將新的結構條目添加到該數組。每次調用函數時 - 數組的空間都應重新分配。 pa->arr = realloc(pa->arr, (pa->count + 1) * sizeof(struct product)); if (pa->arr == NULL) return NULL; 結構的陣列ARR被另一結構結構product_array

    -1熱度

    1回答

    我試圖複製一個char word[50]數組到char **wordlist雙指針,然後realloc(wordlist, (numwords+1)*sizeof(char*))將單詞表的大小再增加一個char*以保存下一個word。 我不斷收到一個錯誤*** glibc detected *** ./program: realloc(): invalid next size 我聲明它作爲word

    0熱度

    1回答

    我正在做一些實驗來理解cpp中的realloc函數。 這是我的代碼 #include <iostream> #include <stdlib.h> using namespace std; class node { public: int value; int count; node(void) { count=5;