懂c语言的看一下,这个程序怎么无法运行

来源:百度知道 编辑:UC知道 时间:2024/03/29 10:05:51
我编了一个程序,目的是把一个文件中的特定字符组合替换成其他字符串,和进行一些修改(如当遇到Son组合时把它后面和';'前的字符串括在括号中存入新的文档),并存入里一个文件中,可是程序无法运行!运行到输出“please enter the filename”后程序就死掉了,无法输入

#include"stdio.h"
#include"string.h"
#define N 3
void writejava(int a,int i,char b[]);
void read(void);
char finishpath[256];
char public[256];
char filename[256];
main()
{
printf("please enter the path of the file: ");
scanf("%s",filename);
printf("ok~plesase enter the path of file finished");
scanf("%s",finishpath);
read();
}
void read(void)
{
int check=0,i=0;
char*cmp[20]={0};
char b[256];
FILE*fp;
cmp[1]="Buf";/*定义代码*/
cmp[2]="Son";
fp=fopen(filename,"r");
do{
check=0;
fscanf(fp,"%s",b);
for(i=1;i<N;i++)
{
if(!strcmp(b,cmp[i])){
check=1;
if(i%2==0)
fscanf(fp,&qu

printf("please enter the path of the file: ");
scanf("%s",&filename);
printf("ok~plesase enter the path of file finished");
scanf("%s",&finishpath);
要加地址符

void writejava(int a,int i,char b[]){
FILE*fp;
char*c[30];
c[0]="\");";

天文,天书!