I am trying to use Ubuntu terminal to display the users input. If the user enters "exit" the program should quit. If the user enters something other then "/dev/pts/1" it should display "Unable to open for writing". The program keeps printing the else statement no matter what I type in. Help please.
#include <stdio.h>
main()
{
FILE *fpt;
char str[100];
char term[20];
fpt = fopen("/dev/pts/1", "w");
while(1)
{
printf("Enter the terminal to display in: ");
scanf("%s", term);
if(term != "exit");
{
if(term == "/dev/pts/1")
{
printf("Enter the text to display: ");
scanf("%s", str);
fprintf(fpt,"%s\n", str);
}
else
{
printf("Unable to open %s for writing\n", term);
}
}
}
fclose(fpt);
}