Ç - 卸下并更换印刷品 [英] C - Remove and replace printed items

查看:79
本文介绍了Ç - 卸下并更换印刷品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我C语言编写的程序在编译的gcc。该问题涉及到的功课,但我需要帮助的具体部分不是家庭作业的一部分。类似的问题被问 Python的 - 移除和更换打印的项目,但我中号不使用Python code。我已经写了大部分的家庭作业的,现在我想增加新的功能。

I'm writing a program in C compiled in gcc. The question relates to homework, but the specific part I need help with is not part of the homework assignment. A similar question was asked Python - Remove and Replace Printed items, but I'm not using Python code. I've written most of the homework assignment, and now I'm trying to add features.

我试图做的第一个问题是打印出一些文字在屏幕上,然后删除该文本,然后打印出新的文字在屏幕上在第一个文本使用的是同一个点。

The first issue I'm trying to do is print out some text onto the screen, then remove that text, then print out new text onto the screen in the same spot where the first text used to be.

例如,我想程序打印快速的棕色狐狸,然后从屏幕上删除棕色狐狸,然后打印青狐,其中使用的棕色狐狸的是,让快速绿色狐狸是最后显示在屏幕上的相同位置

For example, I would like the program to print "Quick brown fox", then remove from the screen "brown fox", then print "green fox" where 'brown fox' used to be, so that "Quick green fox" is displayed lastly on screen in the same location

的另一个问题是,使程序不使用输入键响应于用户输入

The other issue is to have the program respond to user inputs without using the enter key.

我认为这些功能都是可能的,因为我已经运行一个叫乔的从我的系统自己的编辑器程序。在这里面,我可以preSS CTRL-C,其功能类似于一个exit命令,并显示一条消息,失去更改此文件Y,N,^ C)?如果我再preSSN,只有N时,输茶......消息从屏幕上消失,光标位置进行调整。

I think these features are possible, since I've run a program called Joe's Own Editor from my system. In it, I can press ctrl-C, which functions like an exit command, and a message is displayed "Lose changes to this file y,n,^C)?" If I then press "n", and only "n", the "Lose cha..." message is removed from the screen and the cursor location is adjusted.

感谢。

推荐答案

使用 \\ b (退格键)字符。

printf("Quick brown fox");
int i;
for(i=0; i < 9; i++)
{
    printf("\b");
}
printf("green fox\n");

我注意到,把一个 \\ n 上的第一个的printf()搞砸输出。

这篇关于Ç - 卸下并更换印刷品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆