here it is: call them is "lcd_puts(uint2char(1234));" compile, in any following situation, has no error, no warning: PICC -W9 -FAKELOCAL -G9 -O -Zg -D24 -ICD -II:\MY_MCU\MYHWORK I:\MY_MCU\MIV_05.C -16F876A ========= below two fun are the working perfectly==================== char * uint2bcd(unsigned int v){ // char i; unsigned char temp[6]={0,0,0,0,0,0}; // if static, mess up, . no static here. //tried move out as global char []. other use global. but content mess up!!! keep this way //static works at odd int number for uintbcd2char. half workign! while(v>=10000){ temp[0]++; v-=10000; //[0] is biggest digit,,,differ from for hd44100.c and for hd4478 _puts(char *) } while(v>=1000){ temp[1]++; v-=1000; } while(v>=100){ temp[2]++; v-=100; } while(v>=10){ temp[3]++; v-=10; } temp[4]=v; //[5] leave for add end char return temp; //no eof in str } char * uint2char(unsigned int i_num){ char ch[10]={'0','1','2','3','4','5','6','7','8','9'}; char i=0; char * temp; //here is [] will not work. [] only pass add to first??? char tmp; temp = uint2bcd(i_num); //inside it has uchar temp[5],,,[0] is least digit //*(temp+5)='\0'; /* while(*temp){ //pnt instead array below....temp hasn't \0 terminated. can stop here. tmp=ch[*temp]; *temp++=tmp; //here pnt at end...cal below can't do. } temp-=5;//move pnt back original...still doesn't work...add '\0' still don't */ ///* for (i=0;i<6;i++){ tmp=ch[temp[i]]; //bcd char value -> ASCII char temp[i]=tmp; } //*/ return temp; } ===========below is code what I hope to work...but global, static, pass char [6], none of them works!!!!============= char * uintbcd2char( char * temp){ // pointer bring change out char ch[10]={'0','1','2','3','4','5','6','7','8','9'}; char i=0,tmp=0; //char * temp; //here is [] will not work for (i=0;i<6;i++){ tmp=ch[temp[i]]; //bcd char value -> ASCII char temp[i]=tmp; } ////leading '0' changed to space for(i=0;i<4;i++){ //[1] and [0]no need to change back if(temp[i]=='0') temp[i]=' '; //if =0; stop sending to hd44780. so use ' '... ////OK! fix wide of 5 dig...even better else break; //once meets none '0', leading 0 end and out! } temp[5]='\0'; //end char of string...no it, "@_" at end. now, ok! return temp; } ----- Original Message ----- From: "Matthew Miller" To: "Microcontroller discussion list - Public." Sent: Tuesday, June 14, 2005 9:02 PM Subject: Re: [PIC] need to improve skill for picc string and array. my code don't work > On Tue, Jun 14, 2005 at 12:30:24AM -0400, microsoftwarecontrol wrote: > > I tested static inside function and tested > > move it to global. Yes, static made local > > string bring content out, but only when is > > odd number calls and even number calls > > gave either no content or mess up content. > > Half working. > > Hi, > > Would you mind posting the whole source file and the complete error messages > that your compiler produced? This would enable us to help you better. You > are not providing enough information IMO. Just saying "It's not working" is > less than helpful. > > Take care. Matthew. > > -- > QUOTE OF THE MOMENT: > If you didn't get caught, did you really do it? > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist