C语言退行 怎样把光标推到上一行?
1、可以使用顷衫悉gotoxy函数。
原型:extern void gotoxy(int x, int y);
用法:#include system.h
功能:将光标移动到指定位置说明:gotoxy(x,y)将光标移动到指定行y和列x。设置光标到文本屏幕的指定位置,其中参数x,y为文本屏幕的坐标。
2、假设上塌稿一行是屏幕的左上角。
gotoxy(0,0)//雀乎将光标移动到屏幕左上角
C语言,删除一行
删樱亏除文件里的一行内容,后面的行向前移动一行,清脊型神空最后一行租配,程序如下:
假定一行不超过1000字符,
删去第3行,L=3.
输入输出文件名
a.txt
#includestdio.h
void
main()
{
FILE
*fin;
fpos_t
pos_w,pos_r,pos;
int
i,k,L=3;
char
*one_line;
one_line
=
(char
*)
malloc(1000*sizeof(char));
fin
=
fopen
(“a.txt”,”rb+”);
for
(i=1;iL;i++)
fgets(one_line,999,fin);
fgetpos
(fin,pos_w);
fgets(one_line,999,fin);
//
delete
fgetpos
(fin,pos_r);
pos
=
pos_r;
while
(1
==
1)
{
fsetpos
(fin,pos);
if
(fgets(one_line,999,fin)
==NULL)
break;
fgetpos
(fin,pos_r);
pos
=
pos_w;
fsetpos
(fin,pos);
fprintf(fin,”%s”,one_line);
fgetpos
(fin,pos_w);
pos
=
pos_r;
}
pos
=
pos_w;
fsetpos
(fin,pos);
k
=
strlen(one_line);
for
(i=0;ik;i++)
fputc(0x20,fin);
fclose(fin);
}