Simple C Programming question.
1
Name:
Anonymous
2013-06-21 14:45
OK, let's say I have a simple program that uses the printf function to print out "0 1 2 3" from some sort of increment loop.
When the program finishes printing the numbers, they come out as:
0
1
2
3
-----
Ok. Here's my question: How can I make it so that as the program prints out each number, each previous number is replaced by the newer one. So when the program ends, the only think you'll see on the screen is a "3", instead of "0 1 2 3".
This isn't to say that the previous numbers in front of three weren't displayed. It's just that they were displayed and replaced with the next number so quickly that it's hard for the human eye to see them go by.
2
Name:
Anonymous
2013-06-21 15:08
How do I ANSI?
3
Name:
Anonymous
2013-06-21 15:24
ncurses
4
Name:
Anonymous
2013-06-21 15:26
#!/bin/bash
for (( ; ; ))
do
echo 1
clear
echo 2
clear
echo 3
clear
done
5
Name:
Anonymous
2013-06-21 15:59
>>3
OVERKILL IS THE BEST KILL
6
Name:
Anonymous
2013-06-21 18:10
Overkill is underrated.
7
Name:
Anonymous
2013-06-21 18:28
printf("\x1B[A"); moves the cursor up; try doing that after printing a newline.
8
Name:
Anonymous
2013-06-21 18:39
instead of \n, use \r
9
Name:
Anonymous
2013-06-21 18:42
>>4
This will clear out the entire terminal, OP is asking for a method of clearing only the previous line.
10
Name:
Anonymous
2013-06-21 18:53
Yeah do what
>>8 says, just remove the EOL char.
I don't see why you would want to do that tho
11
Name:
Anonymous
2013-06-21 19:40
Make sure you #include <conio.h> and use the clscr() function
12
Name:
Anonymous
2013-06-21 19:56
gotoxy(x,y) where x and y are the coordinates in your terminal.
13
Name:
Anonymous
2013-06-21 20:47
GoToCoordinatesInConsole(x, y, GetConsoleDeviceContext(NULL), NULL, NULL, NULL);
14
Name:
Anonymous
2013-06-21 21:17
//backplate getgoes;
15
Name:
Anonymous
2013-07-02 4:19
>>7
Aren't particular sets of escape sequences tied to a particular type of architecture/terminal, i.e. "implementation-dependent"?
>>11
It would be hard to assume the use of this library nowadays (unless you use something like Borland Turbo C 2.01 on a regular basis).
16
Name:
Anonymous
2013-07-02 6:39
>>15
The
\r escape sequence is defined in the standard.
It would be hard to assume the use of this library nowadays (unless you use something like Borland Turbo C 2.01 on a regular basis).
YHBT
17
Name:
Cudder
!MhMRSATORI!fR8duoqGZdD/iE5
2013-07-02 6:41
/b/ \b, you idiots.
18
Name:
Anonymous
2013-07-02 16:24
>>16
\r is obviously part of the standard. Notice I was referring to
>>7 .
\x1B[A is an ANSI escape sequence and its interpretation is not guaranteed (needs ansi.sys driver on DOS, or some derivative like NNANSI.COM). Unless that was a troll as well.
19
Name:
Anonymous
2013-07-02 17:11
>>18
For some reason I thought you were replying to
>>8 's post instead :/.
20
Name:
Anonymous
2013-07-02 18:08
21
Name:
Anonymous
2013-07-02 21:11
int main(int ac, char ** as){
int i = atoi(as[0]);
if(i > 10){
printf("Please enter a number less than 10");
return -1;
}
for(int x = 0; i > x; x++){
printf("%d\b",x);
}
printf("%d",i);
return 0;
}
22
Name:
Anonymous
2013-07-02 21:45
Argument 0 contains the executable name. I suppose you meant int i = atoi(as[1]);.
23
Name:
Anonymous
2013-07-02 23:30
>>22
Yes. I wrote it in the reply field and never actually bothered to test it, sorry.
24
Name:
Anonymous
2013-07-03 9:39
>>21
type function () {
blag blah
}
EGYPTIAN BRACKETS ARE
PIG DISGUSTING!
25
Name:
Anonymous
2013-07-03 9:55
^H
26
Name:
Anonymous
2013-07-03 18:36
>>25
^H == \b == 0x08
>>24
While K&R, and also (probably as a result of the former) the Linux Coding Style doc do promote the use of such bracketing, it is made clear that function definitions are an exception, and should definitely look like this:
type function()
{
stuff
}
27
Name:
Anonymous
2013-07-03 19:00
>>24
fuck off back to hacker jews, heathen
28
Name:
Anonymous
2013-07-03 19:23
>>27
So you prefer to use
if (condition) {
blah blah
}
over the superior
if (condition)
{
blah blah
}
29
Name:
Anonymous
2013-07-03 21:19
>>28
Not
>>27- tono, but yeah, I prefer more non-fluff lines of code to be displayed at once.
30
Name:
Anonymous
2013-07-03 23:20
LLLEEEEEEEELLLLLLLLLLLLLLL
>LE TOINO XDDDDDDDDD
<>LETONOOOO
>EGIN TONO GROOOOOOOOOOOO!!!!
>EGIN
>EGINNNGGGINNGWOINGOIN GROOOO
>OOLLELELELELELLLLLLLL
31
Name:
Anonymous
2013-07-03 23:33
>>30
It's
``
>LE TOINO XDDDDDDDDD
>EJPIN TONO JPROOOOOOOOOOO!!!
>EJPIN
>EJPIN PEDOPHILIA JPRO!!!!!!!
''
you dumb piece of shit.
32
Name:
Anonymous
2013-07-04 2:35
#include <stdlib.h>
#include <conio.h>
#define void PENISSS
#define ( PENISSSS
#define ) PENISSSSS
#define { PENISSSSSS
#define for PENISSSSSSS
#define int PENISSSSSSSS
#define = PENISSSSSSSSS
#define 1 PENISSSSSSSSSS
#define ; PENISSSSSSSSSSS
#define < PENISSSSSSSSSSSS
#define 4 PENISSSSSSSSSSSSS
#define += PENISSSSSSSSSSSSSS
#define printf PENISSSSSSSSSSSSSSS
#define " PENISSSSSSSSSSSSSSSS
#define %d PENISSSSSSSSSSSSSSSSS
#define , PENISSSSSSSSSSSSSSSSSS
#define clrsc PENISSSSSSSSSSSSSSSSSSS
#define } PENISSSSSSSSSSSSSSSSSSSS
PENISSS PENIS PENISSSS PENISSSSS PENISSSSSS
PENISSSSSSS PENISSSS PENISSSSSSSS PENISS PENISSSSSSSSS PENISSSSSSSSSS PENISSSSSSSSSSS PENISS PENISSSSSSSSSSSS PENISSSSSSSSSSSSS PENISSSSSSSSSSS PENISS PENISSSSSSSSSSSSSS PENISSSSSSSSSS PENISSSSS PENISSSSSS
PENISSSSSSSSSSSSSSS PENISSSS PENISSSSSSSSSSSSSSSS PENISSSSSSSSSSSSSSSSS PENISSSSSSSSSSSSSSSS PENISSSSSSSSSSSSSSSSSS PENISS PENISSSSS PENISSSSSSSSSSS
PENISSSSSSSSSSSSSSSSSSS PENISSSS PENISSSSS PENISSSSSSSSSSS
PENISSSSSSSSSSSSSSSSSSSS
PENISSSSSSSSSSSSSSSSSSSS