Print #'s on total winsize width
This commit is contained in:
parent
92ccea0883
commit
b74d537a86
1 changed files with 10 additions and 0 deletions
10
winsz.c
10
winsz.c
|
|
@ -1,6 +1,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
struct winsize w;
|
struct winsize w;
|
||||||
|
|
@ -17,5 +18,14 @@ int main(void) {
|
||||||
printf("Rows (height): %d\n", w.ws_row);
|
printf("Rows (height): %d\n", w.ws_row);
|
||||||
printf("Cols (width): %d\n", w.ws_col);
|
printf("Cols (width): %d\n", w.ws_col);
|
||||||
|
|
||||||
|
char buf[1024];
|
||||||
|
|
||||||
|
if(w.ws_col < 1024) {
|
||||||
|
memset(buf, '#', w.ws_col);
|
||||||
|
buf[w.ws_col] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s", buf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue