Are you invoking it like ". /tree" or just "tree". It looks like you are trying to run a gui application over ssh.
To see which application try connecting with "ssh -XY HOST" if you are on a linux machine. Then you should see an application launching.
Up vote 0 down vote favorite share g+ share fb share tw.
So I did a bit of C programming a while ago and basically forgot it all lol but anyways I started doing this "C Refresher" thing I found online and was following this binary search tree example kinda loosely and ran into an error. Once I compile it and run it, it says "Error: Can't Open Display". I am running this code on some kinda Linux server in school.
Anyways, here's the code: #include #include #define TRUE 1 #define FALSE 0 typedef struct Node { int value; struct Node *left; struct Node *right; } Node; void add (Node *node, int value) { if (value value) { //left side if (node->left == NULL) { Node *newNode = malloc(sizeof(Node)); newNode->value = value; newNode->left = NULL; newNode->right = NULL; node->left = newNode; } else { add(node->left, value); } } else { //right side if (node->right == NULL) { Node *newNode = malloc(sizeof(Node)); newNode->value = value; newNode->left = NULL; newNode->right = NULL; node->right = newNode; } else { add(node->right, value); } } } int search(Node *node, int value) { if (node == NULL) { return FALSE; } else if (node->value == value) { return TRUE; } else { if (value value) { return search(node->left, value); } else { return search(node->right, value); } } } int main (int argc, char *argv) { Node root; root. Value = 23; root. Left = NULL; root.
Right = NULL; add(&root, 5); add(&root, 50); add(&root, 8); add(&root, 2); add(&root, 34); if (search(&root, 23)) { printf("23 lives in the tree. \n"); } else { printf("23 does not live in the tree. \n"); } if (search(&root, 42)) { printf("42 lives in the tree.
\n"); } else { printf("42 does not live in the tree. \n"); } return 0; } The code might seem long but it is actually pretty basic. I think I coulda cut some of the code out before pasting it here but I figured I would leave everything in in case I took out something vital to the problem.
Also I thought it might have something to do with the Node thing so in my main method I put a quick printf("hi"); before the Node root; to see if that would make a difference but it still gave me the same error. And I have another program on my account on this school server and that program has some printf statements and it runs just fine. I tried Googling the problem but all this weird Linux threads came up and I couldn't really understand it.
My computer is Windows but I did all this coding in a program called emacs that I got to through a program called PuTTY that lets me connect to the school Linux server. Also I compiled it with gcc -o tree tree.c. Sorry for all the writing, I was just trying to give as much information as possible.
Thanks to anyone who can help! C linux error-message binary-tree binary-search link|improve this question asked Feb 17 at 16:22ProgrammingMakesMeQQ82.
– Joachim Isaksson Feb 17 at 16:24 1 "Cannot open display" is an X11 error message. You're not using X at all in that piece of code. Are you sure you're running what you think you're running?
– Mat Feb 17 at 16:24 what does env gives you under DISPLAY variable? Default should be :0.0 – Eregrith Feb 17 at 16:25.
1 or type which treeto figure out what it's actually trying to execute when you type tree – Joachim Isaksson Feb 17 at 16:29 OMG THANK YOU! I guess tree is a Linux command or something, and I was just typing in tree and it was interpreting it as the command rather than my program. OMG thank you so much this has been bugging me all day and just put a halt in all my progress but yeah when I type in .
/tree it works just fine! – ProgrammingMakesMeQQ Feb 17 at 17:38.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.