Hi, On Sun, Jun 12, 2005 at 09:55:59AM -0400, microsoftwarecontrol wrote: > in picc, have functions: You have a couple problems here. Depending on how picc handles somethings, my concerns may not be valid (though I know they would be when using C on a "larger" cpu.) > char * fun(void) > { > char ca[6]={0,0,0,0,0,0}; > > // doing something about ca[] > > return ca; > } Here you are returning a pointer to an array that is allocated on the stack (wherever the stack is on the pic your using). This is bad. The very next function call you make will likely overwrite the contents of the array. > char * fun1(void) > { > char * charpointer; > > charpointer=fun(); //inside fun1 calls fun()...like one fun.... > > return charpointer; > } You make the mistake of using that pointer here in fun1(). > char * fun(voi) > { > char ca[] > > return ca; > } You can't declare an array without also specifying the size of the array. I'm sure that your compiler produces an error concerning the line "char ca[]", though you don't include the error in your email message. Oh, that line is also missing a semicolon. > char * fun2(char * charpointer) // return of fun will be parameter now > { > > charpointer[5]='\0'; > > return charpointer; > } > > /////call: char * pnt=fun2(fun()); ////don't work I believe you need to think through your code a bit more. The mistakes you have made can be easily avoided by heeding the warnings and errors that the compiler reports. Even with no warnings or errors, logic errors may still exist, and some compilers may not issue a warning regarding the type of error that is in your fun(). Take care, Matthew. -- If we don't believe in freedom of expression for people we despise, we don't believe in it at all. -- Noam Chomsky -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist