I'm not sure why those variables aren't available to C programs, but they are apparently set by the OS. This is fairly traditional in the Unix world. The man page for ls in many versions of Unix (including Linux,) states that ls determines how wide to make its output from the variable COLUMNS. If it is unset, ls assumes 80. So, there is a good reason why the OS sets these somewhere. As I said, I don't know why they don't show up with the C programs.