#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