Matching Data Types

Pete Holsberg pjh at mccc.uucp
Tue May 8 03:41:23 AEST 1990


In article <1990Apr30.164553.1693 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
=In article <1990Apr27.000956.13201 at mccc.uucp> pjh at 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 



More information about the Comp.lang.c mailing list