Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
#include<iostream.h>
#include<stdbool.h>  //error in including header file
#include<conio.h>

bool cmp(int,int);  //Declaration error

void main()
{

int a=0,b=1;

cmp(a,b);

getch();

}

bool cmp(int a,int b)  //bool is intialized more than once
{

if(a==b)
return true;
else
return false;

}
Posted
Updated 11-Oct-13 5:53am
v3
Comments
Thomas Daniels 11-Oct-13 11:52am    
Which errors do you get?
kashiiii 11-Oct-13 11:54am    
i have updated the question see again,i mention them
Thomas Daniels 11-Oct-13 11:58am    
Which compiler do you use?
kashiiii 11-Oct-13 12:07pm    
turbo c++


There're is no syntax error in your code snippet. Obviously, the problem is with the compiler. Here it is said that older compilers may not support <stdbool.h></stdbool.h>.

And Turbo C++ ? Really ? You should install a new C++ compiler immediately (Try; CodeBlocks, VC++...). Here're the reasons not to use Turbo C++.
 
Share this answer
 
Comments
kashiiii 22-Oct-13 12:16pm    
I dont Know how to work with other compilers,like code blocks i gave my everything but still cant even execute a simple program in it..it need to be configured properly before first use
Your call to cmp throws away the result, it should be:
C++
void main()
{
    int a=0;
    int b=1;
    bool result;
     
    result = cmp(a,b);
    if (result)
    {
        // the result is TRUE, do something useful
    }
    else
    {
        // the result is FALSE, do something else
    }
         
    getch();
     
}
 
Share this answer
 
Comments
Captain Price 12-Oct-13 9:50am    
This is really weird. What's wrong with not assigning result to cmp(a, b) and just ignoring the return value of cmp(a,b) ?
Richard MacCutchan 12-Oct-13 11:02am    
Read the question.
Captain Price 12-Oct-13 11:40am    
But your answer doesn't clarify the declaration problem.
Richard MacCutchan 12-Oct-13 11:55am    
I don't have turbo C so I cannot clear the errors. Question was about how to use the return value.
kashiiii 22-Oct-13 12:13pm    
I wrote as you told but still compiler give errors:
1:Unable to include stdbool.h
2:declaration error in cmp
3:undefined symbol result

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900