[help] problem on printing message
Posted: Sat Mar 03, 2007 10:35 am
Hi all,
I just try to build a simple kernel from the online tutor...
but there is problem to print the string ( it is ok to print a single charater)
below is the code:
but the following function "puts()" doesnt work when I define the variable as:unsigned char text[]="hello";
if I define it as :
static unsigned char text[]="hello";// work
unsigned char text[]={'h','e','l','l','\0'}; //work
Thanks in advance
I just try to build a simple kernel from the online tutor...
but there is problem to print the string ( it is ok to print a single charater)
below is the code:
Code: Select all
void putch(unsigned char c) // this function is to print a single character
// and work fine
if I define it as :
static unsigned char text[]="hello";// work
unsigned char text[]={'h','e','l','l','\0'}; //work
Code: Select all
void puts(void)
{
int i;
[b]
// unsigned char text[]="hello"; //cannot print the message
// static unsigned char text[]="hello";// work
// unsigned char text[]={'h','e','l','l','\0'}; //work
[/b]
for (i = 0; i < strlen(text); i++)
{
putch(text[i]);
}
}
void main(void)
{
puts();
}