您好我正在研究排序算法,因爲我想做一個簡單的程序從文本文件中獲取整數數組。雖然這樣做我有一些麻煩和問題,關於數組和函數,他們作爲參數。這是我做的:通過任意尺寸的二維數組
#include<stdio.h>
#include<stdlib.h>
#define MAX_SIZE 64
#define MAX_INT_SIZE 10000
void itobuff(const char* istring,const int** sint);
int getistring(FILE* file,char strbuffer[][MAX_SIZE],int max_int,int max);
int main(int argc,char*argv[]){
char buffer[MAX_INT_SIZE][MAX_SIZE];
int int_counter=0;
int int_buffer[MAX_INT_SIZE];
FILE *file = fopen("MYFILE.txt","r");
getistring(file,buffer,MAX_INT_SIZE,MAX_SIZE);
return 0;
}
我的疑問是關於函數
int getistring(FILE* file,char strbuffer[][MAX_SIZE],int max_int,int max);
我想編寫一個函數,它允許使用任何大小的數組的定義。我知道這是錯誤的,但從邏輯上講,這是我想達到的,但無法弄清楚。
int getistring(FILE* file,char strbuffer[][],int max_int,int max);
我知道我想做的事可能會以其他方式完成,但我想知道如何去做。例如,如果我想編寫一個獲取數組的函數並返回該數組的行列式,則不應該強制將自己限制爲k大小的數組。或者更一般地說,用於任何其他數組操作的i-columns,j-rows數組。
謝謝!就我所知,我的主要參考Kernighan&Ritchie沒有包含任何關於可變大小數組的內容。 –