c - Passing values to an function -


I miss a fundamental point on passing the values.

In my code, I have this prototype / function:

  zero droft (four A [], unsigned four lengths, four x1, four y1, uint16 FGcolor);  

I call the function using a call like this:

  Drafton ("William", 7, 15, 25, Yale, 0) ;  

or

  Drafton ("W", 1,15,25, Yale, 0);  

Both of these functions are correct in code. If I check the A [0] in the function, then I will see the value of the '57' representing the ASCII 'W'. All right and good

My question / problem is this: My code fails when I try to use 'W' instead of string representation of ASCII values ​​Example:

 < Code> Droff (57,1,15,25, YEL, 0);  

The value of A [0] in the code is: 0, but the address of A is 57. So somehow the compiler believes that I want to pass a pointer? I am confused, why this string passed fine, but not worth it?

Thanks in advance from a novice C programmer.

Prototype for your function declares that the first parameter is an indicator for a single character:

  zero draw font (four A [], .. ..);  

If you pass an integer, then you are breaking the rules. The compiler should warn about this. func (57) :

  returns a warning about the codes around the zero function (four A []} {} Charm Arm [] = {87,84,70}; int main () {throw (57); function ("w"); function (arrival);}  
< C4047: 'function': 'char *' is different from the level of indirection '' int 'Xc (9): Warning C4024:' class = Func ': Different types for formal and actual parameter 1 1

If you see the assembly output from the compiler, you can You can see more clearly (I cut loose parts):

  public _arr _DATA SEGMENT _arr db 057 h; here in memory one There are four arrays at the address: DB 054HDB 046H ORG $ + 1 $ SG1297DB 'W', 00H; Here is the "w" at an address in the memory (Null-terminated) _DATA ENDS; 9: throw 57); 00003 6A39 Push 57; 57 Press as an address, wrong! 00005 E 800 00 00 00 Call _func 0000a 83C4 04 ESP, 4th; 10: Funk ("W"); 0000 D68 00 00 00 Push Offset $ SG1297; Push the string address 00012 E8 00 00 00 Call _func 00017 83C4 04 ESP, 4th; 11: Funk (AR); 0001a 68 00 00 00 Push OFFSET _arr; Push the array address 0001f e8 00 00 00 Call _func 00024 83 c4 04 esp, 4  

Adding letters is expected to go to an address to read. Who knows what is in the address 57.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -