list directory/file in 2 columns (printf with termcap)?
Hello,
I would like to list files/directory (ls) and printf on 2 columns. I have here a first code, I clear the screen with termcap, opendir and read the files, but how to see width and printf it? Sorry for my very easy question. I am just beginning in programming. Code:
#include <stdio.h> |
Um, ls -c [dirname] or without dirname the current directory.
The brackets enclose optional arguments, don't use them to enclose actual arguments. |
Quote:
Code:
ls -c '/home/daniel/Desktop/Birthdays/' \ |
Hi Guys,
The point is C language using termcap. https://en.wikipedia.org/wiki/C_%28p...ng_language%29 Thank you anyhow for your help and answers |
To get the width of screen (if you have a screen at all), you can use getenv("COLUMNS") and/or ioctl(TIOCGWINSIZ)
|
bucks and ballerinas, you're all missing the point:
Xeratul is set on recreating standard Linux utilities with C. |
I think what you're trying to do is best done with ncurses (if you want to do it in C).
Or, what you have is two arrays of strings (or one big array that you manage with the size of your screen split in half). Either way, you're going to want the size of the screen which you get with ncurse to figure out where to place things. Note that you can do the two columns with a system call in C (that's the easy way): Code:
system ls -c |
Quote:
The reason is that I work on a terminal like screen. |
Here it is.
Code:
#include <stdio.h> |
All times are GMT -5. The time now is 12:15 PM. |