473,378 Members | 1,426 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Pointer to structure required on left side

2
Expand|Select|Wrap|Line Numbers
  1. #include<conio.h>
  2. #include<alloc.h>
  3. #include<string.h>
  4. struct node
  5.     { int info;
  6.      struct node *l;
  7.      struct node *r;
  8.    } *node;
  9. typedef struct node *pt;
  10. void freenode( pt p)
  11.     { freenode(p);}
  12. pt getnode()
  13.     { pt p;
  14.      p=(struct node*)malloc(sizeof(struct node));
  15.      return(p);
  16.    }
  17. void ini (pt *proot)
  18.     { proot=NULL;}
  19. pt makenode(int item)
  20.     { pt p=getnode();
  21.      p->info=item;
  22.      p->l=NULL;
  23.      p->r=NULL;
  24.      return (p);
  25.    }
  26. void makeleft (pt p,int item)
  27.     { if(p==NULL)
  28.            printf("node p is NULL");
  29.      else
  30.              { if(p->l==NULL)
  31.              p->l=makenode(item);
  32.            else
  33.                printf("node p has left son node");
  34.          }
  35.    }
  36. void makeright(pt p,int item)
  37.     {  if(p==NULL)
  38.            printf("node p is NULL");
  39.      else
  40.              { if(p->r==NULL)
  41.              p->r=makenode(item);
  42.            else
  43.                printf("node p has right son node");
  44.          }
  45.      }
  46. void insert(pt proot, int item)
  47.     { pt p;
  48.      if(proot==NULL)
  49.          {    p=getnode();
  50.           p->info=item;
  51.          p->l=NULL;
  52.          p->r=NULL;
  53.          proot=p;
  54.       }
  55.      else
  56.          { if(item==p->info)
  57.           printf("it has already");
  58.         else if (p->info>item)
  59.             insert(p->l,item);
  60.         else
  61.             insert(p->r,item);
  62.       }
  63.    }
  64. pt del(pt p)
  65.     { pt px,f;
  66.      if (p==NULL)
  67.              return (NULL);
  68.      else if (p->l==NULL&&p->r==NULL)
  69.              px=NULL;
  70.      else if(p->l==NULL)
  71.              px=p->r;
  72.      else if(p->r==NULL)
  73.              px=p->l;
  74.      else
  75.          { f=p;
  76.         px=p->r;
  77.         while(p->l!=NULL)
  78.         {    f=px;
  79.                 px=px->l;
  80.         }
  81.       }
  82.      if(f!=p)
  83.         { f->l=px->r;
  84.              px->r;p->r;
  85.           px->l;p->l;
  86.         }
  87.      else
  88.              px->l=p->l;
  89.      freenode(p);
  90.      return(px);
  91.    }
  92. void display (pt *tree,int level)
  93.     { int i;
  94.      if(tree!=NULL)
  95.          {    display(tree->r,level+1);
  96.           printf("\n");
  97.          for (i=0;i<level;i++)
  98.              printf("  ");
  99.          printf("%d",tree->item);
  100.          display(tree->l,level+1);
  101.       }
  102.    }
  103.  
May 3 '14 #1
3 4379
lyhour
2
To everyone please help me for this code , Thank in advance
May 3 '14 #2
techboy
28
which line you getting error and what error you got ?
May 3 '14 #3
weaknessforcats
9,208 Expert Mod 8TB
This code:
Expand|Select|Wrap|Line Numbers
  1. void display (pt *tree,int level)
  2.      { int i;
  3.      if(tree!=NULL)
  4.           {    display(tree->r,level+1);
  5.      etc...
  6.  
shows tree at a pt*. pt itself is a node* so this is really a node** for tree. What you really need is just a node*.

Therefore, change your function argument from pt* to pt and the pointer to structure on left side will disappear.

There are other errors, but this will get you started.
May 6 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Raymond H. | last post by:
Hello, in my vb projet, I put a WebBrowser and when I view the contents of my hard disk with 'WebBrowser1.Navigate "C:\"' I view my directory in the right side only and in the left side it is'nt...
5
by: imranzafar | last post by:
Hi! I am a beginner in C++. This is little assignment. It gives an error "Structure Require on Left Side of dot operator" Can anybody help me what went wrong in this code? #include <conio.h>...
0
by: John T | last post by:
I have the code I need to show a sort icon in the column header of a ListView control. The issue I have is that the image is always on the right side of the column header text. This isn't...
5
by: Amit_Basnak | last post by:
Dear Friends I have been getting the following error Error 185: "WorkFlow_dce.cpp", line 58 # Left side of '->' requires a pointer to class; type found was 'struct WF_SEARCH_WU'....
1
by: mzkpk | last post by:
Hi.. i m generating PDF file by using FPDF class of php it is successfully generated but i want to set image on left side and text on right side but when i display the image the text go to the bottom...
12
by: drsmooth | last post by:
i am working with a vector of pointers to Job class objects(job class is one that i defined) when a person in my game dies, a pointer to the job he once had is added to a vector to track jobs that...
0
by: wildman | last post by:
RE: menu width and background color ? Jusitify menu items on left side?? I probably need to do this a table or span.. I have a horizontal menu i want to be 800 wide with the same background...
3
by: Zhang Weiwu | last post by:
Dear all I got the following HTML: <div id="div1" style="width: 100%; overflow: hidden;"> <table>...</table> </div> The table element is controlled by javascript and grows by width during...
1
by: sneha amte | last post by:
i have done little ass. of student info & i got the error like "structure required on left side of . or .* " can u give me solution on this error as early as possible.thanks in advance.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.