c语言错误问题
--------------------配置:mingw5-CUIDebug,编译器类型:MinGW--------------------正在编译H:\未命名110.c...
--------------------配置: mingw5 - CUI Debug, 编译器类型: MinGW--------------------
正在编译 H:\未命名110.cpp...
[Error] H:\未命名110.cpp:8: error: invalid conversion from `FILE*' to `int'
[Error] D:\C-FREE~1\mingw\include\stdio.h:239: error: too few arguments to function `char* fgets(char*, int, FILE*)'
[Error] H:\未命名110.cpp:8: error: at this point in file
[Error] H:\未命名110.cpp:9: error: invalid conversion from `FILE*' to `int'
[Error] D:\C-FREE~1\mingw\include\stdio.h:239: error: too few arguments to function `char* fgets(char*, int, FILE*)'
[Error] H:\未命名110.cpp:9: error: at this point in file
[Error] H:\未命名110.cpp:10: error: invalid conversion from `FILE*' to `int'
[Error] D:\C-FREE~1\mingw\include\stdio.h:239: error: too few arguments to function `char* fgets(char*, int, FILE*)'
[Error] H:\未命名110.cpp:10: error: at this point in file
[Error] H:\未命名110.cpp:12: error: `transform' was not declared in this scope
[Error] H:\未命名110.cpp:33: error: `turn' was not declared in this scope
[Error] H:\未命名110.cpp:39: error: `i' is not a type
[Error] H:\未命名110.cpp:39: error: `m' has not been declared
[Error] H:\未命名110.cpp:40: error: a function-definition is not allowed here before '{' token
[Error] H:\未命名110.cpp:50: error: expected `}' at end of input
编译中止 H:\未命名110.cpp: 15 个错误, 0 个警告
#include<stdio.h>
int main()
{
FILE*in,*out;
in=fopen("filein.txt","r");
out=fopen("fileout.txt","w");
char s1[100],s2[100],s[100];
fgets(s1,in);
fgets(s2,in);
while((fgets(s,out))!=NULL)
{
transform(s1,s2,s);
fputs(s,out);
}
return 0;
}
char tolower(char c)
{
if( c >='A' && c<='Z')
c=c-'A'+'a';
return c;
}
int transform(char s1[], char s2[],char s[])
{
int i,j,k,t,l;
for(l =0;s2[l] !='\0'; l++);
for(i =0;s[i] !='\0'; i++)
{
for(j=i,k=0;s1[k]!='\0'&&tolower(s[j])== tolower(s1[k]); j++,k++)
;
if(s1[k] == '\0')
{
turn(s,i,l-k);
for(k=0;s2[k]!='\0';i++,k++)
s[i]=s2[k];
}
}
void turn(char s[],i,m)
{
int a,b;
char temp;
for(a=i;s[a]!='\0';a++);
for(c=a-1;c>i;c--)
for(b=c+m-1;b>i;b=b-m)
{
s[b]=s[b-m]
}
} 展开
正在编译 H:\未命名110.cpp...
[Error] H:\未命名110.cpp:8: error: invalid conversion from `FILE*' to `int'
[Error] D:\C-FREE~1\mingw\include\stdio.h:239: error: too few arguments to function `char* fgets(char*, int, FILE*)'
[Error] H:\未命名110.cpp:8: error: at this point in file
[Error] H:\未命名110.cpp:9: error: invalid conversion from `FILE*' to `int'
[Error] D:\C-FREE~1\mingw\include\stdio.h:239: error: too few arguments to function `char* fgets(char*, int, FILE*)'
[Error] H:\未命名110.cpp:9: error: at this point in file
[Error] H:\未命名110.cpp:10: error: invalid conversion from `FILE*' to `int'
[Error] D:\C-FREE~1\mingw\include\stdio.h:239: error: too few arguments to function `char* fgets(char*, int, FILE*)'
[Error] H:\未命名110.cpp:10: error: at this point in file
[Error] H:\未命名110.cpp:12: error: `transform' was not declared in this scope
[Error] H:\未命名110.cpp:33: error: `turn' was not declared in this scope
[Error] H:\未命名110.cpp:39: error: `i' is not a type
[Error] H:\未命名110.cpp:39: error: `m' has not been declared
[Error] H:\未命名110.cpp:40: error: a function-definition is not allowed here before '{' token
[Error] H:\未命名110.cpp:50: error: expected `}' at end of input
编译中止 H:\未命名110.cpp: 15 个错误, 0 个警告
#include<stdio.h>
int main()
{
FILE*in,*out;
in=fopen("filein.txt","r");
out=fopen("fileout.txt","w");
char s1[100],s2[100],s[100];
fgets(s1,in);
fgets(s2,in);
while((fgets(s,out))!=NULL)
{
transform(s1,s2,s);
fputs(s,out);
}
return 0;
}
char tolower(char c)
{
if( c >='A' && c<='Z')
c=c-'A'+'a';
return c;
}
int transform(char s1[], char s2[],char s[])
{
int i,j,k,t,l;
for(l =0;s2[l] !='\0'; l++);
for(i =0;s[i] !='\0'; i++)
{
for(j=i,k=0;s1[k]!='\0'&&tolower(s[j])== tolower(s1[k]); j++,k++)
;
if(s1[k] == '\0')
{
turn(s,i,l-k);
for(k=0;s2[k]!='\0';i++,k++)
s[i]=s2[k];
}
}
void turn(char s[],i,m)
{
int a,b;
char temp;
for(a=i;s[a]!='\0';a++);
for(c=a-1;c>i;c--)
for(b=c+m-1;b>i;b=b-m)
{
s[b]=s[b-m]
}
} 展开
1个回答
展开全部
#include<stdio.h>
int transform(char *, char *, char *);
void turn(char *, int, int);
int main()
{
FILE*in,*out;
in=fopen("filein.txt","r");
out=fopen("fileout.txt","w");
char s1[100],s2[100],s[100];
fgets(s1, 100, in);
fgets(s2, 100, in);
while((fgets(s, 100, out))!=NULL)
{
transform(s1,s2,s);
fputs(s,out);
}
return 0;
}
char tolower(char c)
{
if( c >='A' && c<='Z')
c=c-'A'+'a';
return c;
}
int transform(char s1[], char s2[],char s[])
{
int i,j,k,l;
for(l =0; s2[l] !='\0'; l++);
for(i =0; s[i] !='\0'; i++)
{
for(j=i,k=0; s1[k]!='\0'&&tolower(s[j])== tolower(s1[k]); j++,k++)
;
if(s1[k] == '\0')
{
turn(s,i,l-k);
for(k=0; s2[k]!='\0'; i++,k++)
s[i]=s2[k];
}
}
return 0;
}
void turn(char s[],int i, int m)
{
int a,b,c;
for(a=i; s[a]!='\0'; a++);
for(c=a-1; c>i; c--)
for(b=c+m-1; b>i; b=b-m)
{
s[b]=s[b-m];
}
}
只保证编过,对错自理吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询