This is the code I was testing, but for some reason the output I get is nothing.
#include <stdio.h>
#include <stdlib.h>
int main (int argc,char*argv[], char *envp[]){
FILE *fp;
char path[1035];
fp=popen("/bin/echo ${COLUMNS}","r");
if (fp==NULL){
printf("hubo un error");
return 1;
}
while (fgets(path,sizeof(path)-1,fp)){
printf("%s",path);
}
pclose(fp);
return 0;
}
The question is:
How do I get the shell variable $ COLUMNS in c language, by linux ?, or what I'm missing or am I doing wrong?
I appreciate your interest