uint8与与或监测【c/c++课程】
// uinttest.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> #ifndef GENERIC #define GENERIC #endif using namespace std; typedef unsigned char uint8; //!< Unsigned 8 bit integer typedef unsigned short uint16; //!< Unsigned 16 bit integer uint8 uartbuf[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint8 UartRxBuf[2]; void Start_UartSend(uint8 *buf, uint16 len) { for (uint8 i = 0; i<len; i++) uartbuf[i] = buf[i]; } uint16 IOTest_Result = 0; //IO检测结果 uint16 IOTest_Result1 = 0; //第1次检测 uint16 IOTest_Result2=0; //第2次检测 int _tmain(int argc, _TCHAR* argv[]) { #if 1 uint8 IO_Test_CMDA[6] = { 'A', 'T', '+', 'I', 'O', 'A' }; uint8 IO_Test_CMDB[6] = { 'A', 'T', '+', 'I', 'O', 'B' }; Start_UartSend(IO_Test_CMDA, 6); //uartbuf[6] = '\0'; #endif IOTest_Result2 |= (1 << 2); IOTest_Result1 |= (1 << 2); IOTest_Result = IOTest_Result1&IOTest_Result2; std::cout << sizeof(uint8) << std::endl; std::cout << uartbuf << std::endl; std::cout << IOTest_Result1 << endl; system("PAUSE"); return 0; }