View previous topic :: View next topic |
Author |
Message |
najhan88
Joined: 06 Apr 2011 Posts: 7
|
undefined identifier get_long |
Posted: Wed Apr 06, 2011 11:11 pm |
|
|
#include <16f877a.h>
//#include <protoalone.h>
//#include <stdlib.h>
//#include <input.c>
//#fuses HS,NOLVP,NOWDT
//#use delay(clock=20000000)
//#use rs232 (baud=9600,xmit=PIN_C6,rcv=PIN_C7)
//#include <16F877A.H>
//#fuses XT, NOWDT, BROWNOUT, PUT, NOLVP
#fuses NOWDT,HS, NOPUT, NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
void main()
{
char gender;
long int w,h,result;
printf("\r\nBody Mass Index");
{
printf("\r\nChoose Your Gender(Male or Female):");
gender=getc();
if(gender=='M')
{
printf("\r\nInsert Your Weight(kg):");
w=get_long();
printf("\r\nInsert Your Height(m):");
h=get_long();
result=w/(h*h);
printf("\r\nYour BMI Result is %lu:",result);
}
}
why get_long error? |
|
|
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Wed Apr 06, 2011 11:37 pm |
|
|
Is your get_long() function defined as long int? |
|
|
najhan88
Joined: 06 Apr 2011 Posts: 7
|
|
Posted: Wed Apr 06, 2011 11:43 pm |
|
|
Sid2286 wrote: | Is your get_long() function defined as long int? |
yeah..i already change it to long int..but its still error |
|
|
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Wed Apr 06, 2011 11:50 pm |
|
|
Can you show the get_long function? is your return type also long int? |
|
|
najhan88
Joined: 06 Apr 2011 Posts: 7
|
|
Posted: Thu Apr 07, 2011 12:00 am |
|
|
Sid2286 wrote: | Can you show the get_long function? is your return type also long int? |
this program also get_long error
#include <protoalone.h>
#include <utility.c>
#include <stdlib.h>
#include <input.c>
void main()
{ long a,b,result;
char opr;
while(TRUE)
{ printf("\r\nEnter the first number: ");
a=get_long();
do
{ printf("\r\nEnter the operator (+-*/): ");
opr=getc();
printf("%c\n",opr);
} while(!isamoung(opr,"+-*/"));
printf("\r\nEnter the second number: ");
b=get_long();
switch(opr)
{ case '+' : result= a+b; break;
case '-' : result= a-b; break;
case '*' : result= a*b; break;
case '/' : result= a/b; break;
}
printf("\r\nThe result is %lu ",result);
}
} |
|
|
najhan88
Joined: 06 Apr 2011 Posts: 7
|
|
Posted: Thu Apr 07, 2011 12:02 am |
|
|
Sid2286 wrote: | Can you show the get_long function? is your return type also long int? |
i write long w,h,result;
also get same error |
|
|
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Thu Apr 07, 2011 12:08 am |
|
|
I can't see your get_long function so I cannot comment how it works!
So to check the rest of the code, I simply added
Code: |
int16 get_long()
{
int16 x;
return(x);
} |
to the previous code and it complies properly.
Sid |
|
|
najhan88
Joined: 06 Apr 2011 Posts: 7
|
|
Posted: Thu Apr 07, 2011 12:13 am |
|
|
Sid2286 wrote: | I can't see your get_long function so I cannot comment how it works!
So to check the rest of the code, I simply added
Code: |
int16 get_long()
{
int16 x;
return(x);
} |
to the previous code and it complies properly.
Sid |
why you put int16?what function its? |
|
|
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Thu Apr 07, 2011 12:16 am |
|
|
Its same as long int you can also try with
Code: |
long int get_long()
{
long int x;
return(x);
}
|
It still complies properly.
Sid |
|
|
najhan88
Joined: 06 Apr 2011 Posts: 7
|
|
Posted: Thu Apr 07, 2011 12:25 am |
|
|
Sid2286 wrote: | Its same as long int you can also try with
Code: |
long int get_long()
{
long int x;
return(x);
}
|
It still complies properly.
Sid |
okey..also same error..
when i enable
#include <stdlib.h>
#include <input.c>
error get_long gone but error
undefined identifier putchar & getchar |
|
|
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Thu Apr 07, 2011 12:38 am |
|
|
Please use in following order.
Code: |
#include <16f877a.h>
//#include <protoalone.h>
//#fuses HS,NOLVP,NOWDT
//#use delay(clock=20000000)
//#use rs232 (baud=9600,xmit=PIN_C6,rcv=PIN_C7)
//#include <16F877A.H>
//#fuses XT, NOWDT, BROWNOUT, PUT, NOLVP
#fuses NOWDT,HS, NOPUT, NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include <stdlib.h>
#include <input.c>
|
It will work ;)
Sid |
|
|
najhan88
Joined: 06 Apr 2011 Posts: 7
|
|
Posted: Thu Apr 07, 2011 12:40 am |
|
|
Sid2286 wrote: | Please use in following order.
Code: |
#include <16f877a.h>
//#include <protoalone.h>
//#fuses HS,NOLVP,NOWDT
//#use delay(clock=20000000)
//#use rs232 (baud=9600,xmit=PIN_C6,rcv=PIN_C7)
//#include <16F877A.H>
//#fuses XT, NOWDT, BROWNOUT, PUT, NOLVP
#fuses NOWDT,HS, NOPUT, NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include <stdlib.h>
#include <input.c>
|
It will work ;)
Sid |
wow..thnks dude |
|
|
|