实例如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include<stdio.h> #include<stdlib.h> #define maxn 200 void main() { FILE *fp; int s[maxn][maxn]; int i,j; if ((fp= fopen ( "d:\\temp\\test.txt" , "r" ))==NULL) { printf ( " can't open" ); exit (0); } for (i=0;i<maxn;i++) { for (j=0;j<maxn;j++) { fscanf (fp, "%d" ,&s[i][j]); } } } |
以上就是小编为大家带来的C读txt到二维数组的实现方法全部内容了,希望大家多多支持服务器之家~