iscntrl(c)?

Discuss Programming

iscntrl(c)?

Postby ZiaTioN » Fri Oct 08, 2004 7:47 pm

I am trying to refresh my shell prompt for each iteration of a loop for a program I am working on. I have read that the control key that does this is CNTRL-L so I went to http://crasseux.com/books/ctutorial/Cha ... table.html and found in this conversion table the information for CTRL-L:

12 14 C CTRL-L


Now the 12 is Decimal, 14 is Octall and the C is hex. How would the syntax look if I wanted to print this control character to screen to refresh the screen?

Here is what I have now:

printf(iscntrl(12));


Of course I get the following error with this syntax:

[root@Hackbox root]# make
g++ -g -o udp_send udp_send.c -lnsl
udp_send.c: In function `int main(int, char**)':
udp_send.c:69: invalid conversion from `int' to `const char*'
make: *** [udp_send] Error 1


Any ideas?
ZiaTioN
administrator
administrator
 
Posts: 460
Joined: Tue Apr 08, 2003 3:28 pm

Postby Void Main » Fri Oct 08, 2004 8:55 pm

You want to refresh your screen or clear your screen? I'm not quite sure why you would need to refresh your screen, can you provide an example of what you are doing and why it needs to be done? Just curious...
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby ZiaTioN » Fri Oct 08, 2004 9:21 pm

Yeah I know it is a weird request. However I found out a method to use that suffices.

Code: Select all
system("clear");


I messed around a bit with refresh() and endwin() but this more along the lines for realtime character management.
ZiaTioN
administrator
administrator
 
Posts: 460
Joined: Tue Apr 08, 2003 3:28 pm

Postby Void Main » Fri Oct 08, 2004 9:43 pm

Ahhh, so it was "clear" that you wanted. I was thinking CTRL+L like in VIM which actually does a refresh. Although this is a little dependent on terminal type you could also elinminate the system call by:

Code: Select all
printf("\e[H\e[2J");


The way I came up with the above is by doing a "clear | od -c". That escape sequence is what the clear command sends to the terminal in a terminal (TERM=xterm). At the console (TERM=linux) it sends a "\e[H\e[J" (no 2). Either one seems to work in either terminal type (but may not work in every terminal). And I certainly wouldn't include curses just to clear the terminal.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron