Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!ncar!mephisto!udel!princeton!njsmu!mccc!pjh From: pjh@mccc.uucp (Pete Holsberg) Newsgroups: comp.lang.c Subject: Re: Matching Data Types Message-ID: <1990May7.174123.22104@mccc.uucp> Date: 7 May 90 17:41:23 GMT References: <1990Apr27.000956.13201@mccc.uucp> <1990Apr30.164553.1693@utzoo.uucp> Reply-To: pjh@mccc.UUCP (Pete Holsberg) Organization: The College On The Other Side Of U. S. One Lines: 36 In article <1990Apr30.164553.1693@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: =In article <1990Apr27.000956.13201@mccc.uucp> pjh@mccc.uucp (Pete Holsberg) writes: =>Suppose one defines => int ch; =>and later, in the same function, begins a loop with => while((ch = getchar()) != EOF) =>Also suppose there is another function defined as => void fun(char c) =>and the first function calls it with => fun(ch); =>What is the passing mechanism that permits this to work? Does the =>function "fun" expect an int because c is a char? How does promotion =>(and demotion) work here? = =There are two cases. First case is when a prototype for fun() is visible =at the point where it is called; What do you mean by a prototype being visible at the point where fun() is called? =in that case, the expressions in the =argument lists are converted to the desired types, as if by assignment =to variables of those types, and there is no problem. So the char that fun() seems to expect is really an int??? That is, fun() picks an int off the stack and converts it to a char?? Or does the calling function convert ch to a char before it pushes the value? Thanks, Pete -- Prof. Peter J. Holsberg Mercer County Community College Voice: 609-586-4800 ext 371 Engineering Technology, Computers and Math 1200 Old Trenton Road, Trenton, NJ 08690 UUCP:...!princeton!mccc!pjh