【发布时间】:2015-07-03 23:50:56
【问题描述】:
#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:这个程序完成后会在控制台显示一张图片。 “** **”是我工作的地方。
【问题讨论】:
-
请正确格式化!
-
我没有看到任何 git pull。什么意思?
-
缩进,[已编辑]。你会用吗?
-
第四个值是什么?
标签: c arrays multidimensional-array console