• C

Find unix TERM within C program.

I am writing a file viewer, which will be used on different terminals in Unix environment. How can I find the current terminal type from within my C program. I tried using the following code:

char *str1;

str1 = (char *)(system("echo $TERM"));
printf("Terminal Type is: %s\r\n", str1);

But, it only echos the term type on the screen, and does not send anything in the variable str1. Any suggestions??
thetaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
rbrConnect With a Mentor Commented:
use

str1=getenv("TERM");

you have to include stdlib.h

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.