View previous topic :: View next topic |
Author |
Message |
young
Joined: 24 Jun 2004 Posts: 285
|
atoi How about itoa |
Posted: Fri Jun 25, 2004 8:01 am |
|
|
Hi:
I knew that CCS have a built in function as atoi, is that also possible to use itoa function?
Thank you |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Fri Jun 25, 2004 8:23 am |
|
|
I compiled the file just using char a=itoc(8), I already include <stdlib.h,> error as undefined identifier itoc, so I believe itoc is not support in CCS. any other opinions. |
|
|
valemike Guest
|
|
Posted: Fri Jun 25, 2004 8:24 am |
|
|
There doesn't seem to be an itoa() function in the documentation, so you'll have to make your own.
I think the K&R book has an example you can copy. |
|
|
Darren Rook
Joined: 06 Sep 2003 Posts: 287 Location: Milwaukee, WI
|
|
Posted: Fri Jun 25, 2004 8:30 am |
|
|
Look at sprintf() |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Fri Jun 25, 2004 9:25 am |
|
|
Thanks
when I complied this following program, an error, an expression must evalust to constant occcured, how to correct it.
char PinNum[7];
int i;
for(i=0;i<7;i++)
{
sprintf(PinNum,"PIN_B%u",i);
output_high(PinNum);
delay_ms(20);
output_low(PinNum); |
|
|
Darren Rook
Joined: 06 Sep 2003 Posts: 287 Location: Milwaukee, WI
|
|
Posted: Fri Jun 25, 2004 10:04 am |
|
|
young wrote: | Thanks
when I complied this following program, an error, an expression must evalust to constant occcured, how to correct it.
char PinNum[7];
int i;
for(i=0;i<7;i++)
{
sprintf(PinNum,"PIN_B%u",i);
output_high(PinNum);
delay_ms(20);
output_low(PinNum); |
Unfortunately output_high() and output_low() requires a constant integer. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 25, 2004 1:14 pm |
|
|
Quote: | when I complied this following program, an error, an expression
must evaluate to constant occcured, how to correct it.
output_high(PinNum); |
Look at the following thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=18233
Mark has posted two functions for output_high and
output_low that let you pass a CCS-style pin number
to the functions as a variable, instead of a constant.
Look for these function names in his post:
my_output_high()
my_output_low() |
|
|
|