#include <stdio.h>
#include <stdlib.h>
int main() {
int *width;
int *height;
int row;
int column;
int character;
int count;
int pictureit;
double i = 0;
FILE *fp;
char file[50];
char line[25]; // assume each line has max 25 characters
printf("What file should we pull from: ");
scanf("%s", file);
//read file using File pointer
fp = fopen(file, "r");
// read the first line in the file
fgets(line, sizeof(line), fp);
width = strtok(line,"x");
height = strtok(NULL, "/0");
// read all the future lines in the file excluding the first
while (fgets(line, sizeof(line), fp)) {
row = strtok(line, ",");
column = strtok(NULL, ",");
character = strtok(NULL, ",");
count = strtok(NULL, "/0");
if(i < count) {
**printf("%s", pictureit[row][column] = character);**
i++;
}
}
fclose(fp);
return 0;
}
我拉在一個文件中使用了這種設置多維數組與未知項目
的75x53
0,36,.,1
0,37,M,1
1,32,.,1
1,33,:,1
1,34,A,1
1,35,M,2
1,37,O,1
1,38,:,1
2,23,.,1
2,24,:,1
2,25,A,1
2,26,M,5
我一直在集思廣益一會兒。我將如何去在控制檯上顯示它?它顯然需要進入二維數組。該程序需要知道陣列的高度和寬度,以在該位置顯示空格或字符。
PS:該程序完成後將在控制檯中顯示一張圖片。 「** **」是我工作的地方。
請盟友適當的格式化! – Olaf
我沒有看到任何git拉。你什麼意思? – Olaf
[如何將序列號(例如:0,36,。,1)更改爲項目(例如:行,列,字符,計數)](http://stackoverflow.com/questions/31214251/how- to-change-sequential-numbers-ex-0-36-1-items-ex-row-column-char) – Olaf