请指正!!!!
#include
main()
{
int i;
char s[100 + 1];
char filename [50 + 1];
FILE *fp = NULL;
scanf("输入100个以内英文字母:%100[a-z] %s",s);
for(i=0; i
if(( fp = fopen( "../123.txt", "w+" )) == NULL )
fprintf( stderr, "创建文件 123.txt 失败!\n");
if (fputs( s, fp ) == 0)
fprintf( stderr, "文件123.txt 写入失败!\n");
}
????
form上加一个Memo,三个按钮
代码如下:
//转为大写
procedure TForm1.Button1Click(Sender: TObject);
var
ls_str: string;
ls_strEnd: string;
begin
ls_str := Memo1.Text;
ls_strEnd := UpperCase(ls_str);
Memo1.Clear;
Memo1.Text := ls_strEnd;
end;
//转为小写
procedure TForm1.Button2Click(Sender: TObject);
var
ls_str: string;
ls_strEnd: string;
begin
ls_str := Memo1.Text;
ls_strEnd := LowerCase(ls_str);
Memo1.Clear;
Memo1.Text := ls_strEnd;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Memo1.Text := '';
end;
//保存
procedure TForm1.Button3Click(Sender: TObject);
begin
Memo1.Lines.SaveToFile('abc.txt');
end;
#include
int main(void)
{
char ch;
FILE *fp = fopen("abc.txt", "w+");
if(fp == NULL)
{
printf("打开文件失败!");
return -1;
}
while((ch = getchar()) != '!')
{
if(ch >= 'a' && ch <= 'z')
ch -= 32;
fputc(ch, fp);
}
fclose(fp);
fp = NULL;
}