我有一个档案名为 4.txt
内容为
i have a pen
she is a girl
出现在哪一行
i 1
have 1
a 1,2
pen 1
she 2
is 2
a 1,2
girl 2
请问怎麼做出以上的功能??
--------------------------
我 是使用 DEV C++ 编译程式的,请帮忙谢谢。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define max 30
int main()
{
FILE *A;
char *temp1[max][max];
char *str1[max][max]; /* fscanf 读取内容时候使用 */
int x=0,y=0;
int c[max];
if((A=fopen("4.txt","r"))==NULL)
{
printf("Open Fail");
}
else
{
printf("Open Success\n");
while(!feof(A))
{
fscanf(A," %s",str1[x]);
printf(" %s\n",str1[x]);
if(str1[0][x]=="") 我原本是想说在这里 判断到若是 换行的话
y++ 那麼 这里就 ++
c[x]=y;//将 数值 存入 整列
这个部份思路有错误,因此 请 大家 教教我,我该怎麼 完成上述的结果,谢谢~~~
x++;
}
}
system("pause");
return 0;
}
内容为
i have a pen
she is a girl
出现在哪一行
i 1
have 1
a 1,2
pen 1
she 2
is 2
a 1,2
girl 2
请问怎麼做出以上的功能??
--------------------------
我 是使用 DEV C++ 编译程式的,请帮忙谢谢。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define max 30
int main()
{
FILE *A;
char *temp1[max][max];
char *str1[max][max]; /* fscanf 读取内容时候使用 */
int x=0,y=0;
int c[max];
if((A=fopen("4.txt","r"))==NULL)
{
printf("Open Fail");
}
else
{
printf("Open Success\n");
while(!feof(A))
{
fscanf(A," %s",str1[x]);
printf(" %s\n",str1[x]);
if(str1[0][x]=="") 我原本是想说在这里 判断到若是 换行的话
y++ 那麼 这里就 ++
c[x]=y;//将 数值 存入 整列
这个部份思路有错误,因此 请 大家 教教我,我该怎麼 完成上述的结果,谢谢~~~
x++;
}
}
system("pause");
return 0;
}