i m trying to make a function which will calculate size of each node of an ordered statistic tree . here size refers to the number of nodes in left sub tree and right sub tree plus one...
but whenever i call this function compiler gives error....and program terminates at line:
if(ptr->lc==NULL && ptr->rc==NULL) -
size(struct node *ptr)
-
{
-
if(root==NULL)
-
{
-
-
return 0;
-
}
-
if(ptr->lc==NULL && ptr->rc==NULL)
-
ptr->size=1;
-
if(ptr!=NULL)
-
ptr->size=(size(ptr->lc) + size(ptr->rc)+1);
-
-
}
-
plz help out by advising me
6 1277 Banfa 9,065
Recognized Expert Moderator Expert
Please use the [code]...[/code] tags provided.
What compiler error do you get?
What do you think this function does it it is called with a NULL pointer?
Please use the
tags provided.
What compiler error do you get?
What do you think this function does it it is called with a NULL pointer?
for your convenience ,to understand wat actually is done...i m putting the whole program :
and the error is general protection exception and line :if(ptr->lc==NULL && ptr->rc==NULL) i.e. line no 68..
is highlighted...i want to know what is wrong....
Banfa 9,065
Recognized Expert Moderator Expert
and the error is general protection exception and line :if(ptr->lc==NULL && ptr->rc==NULL) i.e. line no 68..
is highlighted...i want to know what is wrong....
I have removed you code because a) it is against our posting guideline to post the full code solution to what may be a coursework problem and b) it is not required your original snippet contains all that is required to diagnose the problem.
A "general protection exception" is not a compiler error it is a runtime error, getting the terminology right will help in getting your problem fixed.
And I ask you again what do you think is happening in your function when it is called with a NULL pointer, i.e. when ptr == NULL? If it isn't obvious to you then I suggest you step through each line of code in the function on paper executing it as your processor would.
No its not dude,
I believe the rules say, when you are asking a question it is alright to post entire code. The rules are asking the experts not to post entire code solutions, and that makes sence.
edit:
Sorry guess the rule was changed again. My bad... dont agree with it tho, if you are asking a question, should be aloud to post full code. anyways.
No its not dude,
I believe the rules say, when you are asking a question it is alright to post entire code. The rules are asking the experts not to post entire code solutions, and that makes sence.
edit:
Sorry guess the rule was changed again. My bad... dont agree with it tho, if you are asking a question, should be aloud to post full code. anyways.
thank you for your valuable suggestions
thanks for your valuable suggestions .....banfa
Banfa 9,065
Recognized Expert Moderator Expert
edit:
Sorry guess the rule was changed again. My bad... dont agree with it tho, if you are asking a question, should be aloud to post full code.
Nope they have been that way since about this time last year, I should know I wrote them :D
It's like that for the protection of the poster as much as anything else.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Wayno |
last post by:
My php logs are coming up empty. I have done all I can think of, and
all that made sense to me. Can someone take a look at my php.ini
please and tell me what you think may be the problem.
I double-checked the path to my error log. It is in
/var/www/logs/php_error_log
Thanks. :)
-Wayne Stevenson
|
by: Victor |
last post by:
I'm trying to run this java program, but somehow the program always
quit w/o giving any error msg at all. it happenned inside the first
case statements. Strangely, after printing happen2, it just stopped,
and I had no idea what happens.
another error is on the last function. I have already declared plane
as M x N array, but it keeps giving error like
hwone.cpp(50) : warning C4101: 'plane' : unreferenced local variable
hwone.cpp(212) :...
|
by: sriram |
last post by:
I have the following:
class BSA
{
...
...
...
...
public:
enum VRGAttrId {
|
by: Dalan |
last post by:
Please help - just take a quick look at the function code below. It
probably just needs some minor tweaking.
The function module is based on an intermediate query to provide a
group record total from a subform that is posted to a field on the
main form. "Everything seems to work fine" except that I consistently
receive an error everytime I attempt to create a new record on the
main form. However, there are no errors received when...
|
by: drumdawg21 |
last post by:
Ive been working on this problem for a long time now and really need some help. I have a program in c++ code that gives me build errors and my program is having problems. I have two source files in my project and a header file. The header file(.h) contains the class, there is a main.cpp which contains the main part of the program and another .cpp file which contains the member functions of the class
My problem is that when i create a project...
| |
by: Issac |
last post by:
Hi,
I am working on error handling for my project.
I got the following code from the web which declare that
it can catch all exceptions in my project rather that
using TRY CATCH in everything single sub/function.
\\\
Public currentdomain As AppDomain
|
by: mario.zoric |
last post by:
Hi to all!
I have one big problem. I have written some code and I want to program
at the end looks good but theres one uninspected error.
What's going on?
I have written code for programm that needs to do input, output and
searching, for looking better i wanted to use simple DOS word cls
but(!!!!) in C/C++ there i cant use it. so I looked over the internet
and nearest i could find it's this code:
void gotoxy(int, int); // prototype
|
by: dasilva109 |
last post by:
Hi guys
I am new to C++ and need urgent help with this part of my code for a
uni coursework I have to submit by Thursday
//ClientData.h
#ifndef CLIENTDATA_H
#define CLIENTDATA_H
#include <string>
|
by: cpptutor2000 |
last post by:
Could someone please help me? I have the following C struct.
typedef struct
_FIREWALL_RULE_INFO
{
ULONG Precedence;
BOOL bEnabled;
BOOL bLoggingEnabled;
BOOL bAllowFragments;
BOOL bAllowInbound; /* only used
if 'SohoFirewallModel' is enabled */
|
by: jonatan |
last post by:
Hello All,
I am making a program and need the grt_main.c but i try to compile have the error c1004.Please help me how to solve it?
Thank you.
--------------------Configuration: pre - Win32 Debug--------------------
Compiling...
pre.c
c:\matlab6p5\work\penat\grt_main.c(661) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |