弱弱的问个问题,关于C的

[复制链接]
2205|2
 楼主| xqhe 发表于 2007-3-20 11:24 | 显示全部楼层 |阅读模式
pi, AD, dc, TE, WRITE
    bit x;
    ……
    …… 
    x = Read_Bit_P1(0);   // Read Port 1, Pin 0
    ……
    ……
bit Read_Bit_P1(unsigned char Pin)
   {
   unsigned char p = 1;
   p <<= Pin;  // Left shift
   
   // Write a 1 to the pin (to set up for reading)
   Write_Bit_P1(Pin, 1);
   return (P1 & p); // Read the pin
   }
为什么return (P1 & p); 是返回bit类型的,而不是char类型的?
ayb_ice 发表于 2007-3-20 11:27 | 显示全部楼层

随便说说

bit Read_Bit_P1(unsigned char Pin)定义时返回值是bit型,编译器会将任何类型强制转换为bit.
 楼主| xqhe 发表于 2007-3-21 08:51 | 显示全部楼层

回复

   3Q~~~~~!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

15

主题

46

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部