From: Vic Newsgroups: comp.os.msdos.djgpp Subject: Re: Program with functions Date: Sat, 08 Nov 1997 22:13:36 -0500 Organization: Communications Accessibles Montreal, Quebec Canada Lines: 33 Message-ID: <34652A60.2593@cam.org> References: <199711082153 DOT QAA22413 AT delorie DOT com> NNTP-Posting-Host: dynamicppp-231.hip.cam.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk sl wrote: > char *add(char *first, char*second) > { > int result; > result=first+second; > return(result); > } It's normal that you get problems from this code, and it has nothing to do with what you said... in C '*' means pointer. so your function accepts 2 pointers to ints and returns an int pointer. result=first+second does not add values, it adds pointers. You could re-write the function as char add(char first, char second) { return(first+second); } or, if you *REALLY* want a pointer returned and 2 pointers passed, do this: (a lot more complicated tho) char *add(char *first, char *second) { int *result; result=(int*)malloc(sizeof(int)); (*result)=(*first)+(*second); return (result); } -- --> http://www.cam.org/~tudor <-- "Sex is not the answer. Sex is the question. Yes is the answer."