Discussion in "Software" started by    aj1    Nov 18, 2008.
Tue Nov 18 2008, 03:09 am
#1
i am writing program that calculate the power value. this program below giving me errors.
can some one help me please?

#include "C:\egnu110\include\hcs12.h"
#include "C:\egnu110\include\delay2.c"
#include "c:\egnu110\include\stdio.c"

const char *msg = "Enter a decimal number\n";
const char *msg1 = "Enter a power of decimal number\n";
const char *msg2 = "The Value is = ";
int calcpower(int base,int expo);

int main(void)
 {
int base=0,expo=0;
puts (msg);
base = getch();
puts (msg1);
expo = getch();
return 0;
}
calcpower(int base, int expo)
{
int i=0, val=1, buf[4];
while(i<expo){
val=val*base;
i++ ;
newline();
newline();
int2alpha(val,buf);
puts(msg2);
puts(val);
putsr(&buf[0]);
}
}


[ Edited Tue Nov 18 2008, 12:05 pm ]
Tue Nov 18 2008, 12:08 pm
#2
are you getting any errors...?
what is the o/p?
Tue Nov 18 2008, 08:20 pm
#3
i am getting two errors.
1.passing arg 1 of `puts' makes pointer from integer without a cast
2.passing arg 1 of `putsr' from incompatible pointer type
Thu Nov 20 2008, 09:20 pm
#4
anyone can tell me what is wrong with my program please?
Fri Nov 21 2008, 08:31 am
#5


anyone can tell me what is wrong with my program please?

aj1



Oh alright

>1.passing arg 1 of `puts' makes pointer from integer without a cast
>puts(val);

puts expects to be given a message to print, and val is an integer (a number)
You have to convert val to a string (text) before you can print it.

A lot depends on the flexibility of your compiler, but you have defined buf as a string
of integers and putsr probably expects a string of chars
try
char buf[20];

then
putsr(buf);
putsr(buf[0])
putsr(&buf[0]);

then ask again








[ Edited Fri Nov 21 2008, 08:43 am ]

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Sazrfci
Sun Oct 06 2024, 06:33 am
Sazrzhk
Sun Oct 06 2024, 01:34 am
Sazrjgz
Sun Oct 06 2024, 01:23 am
Dnrthvf
Sat Oct 05 2024, 08:39 pm
Dnrthwo
Sat Oct 05 2024, 08:27 pm
Mofredka
Sat Oct 05 2024, 03:43 pm
ErnestClagS
Sat Oct 05 2024, 06:44 am
Arisha4Et
Fri Oct 04 2024, 05:53 pm