⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 byteorder.c

📁 variable concept for embedded systems
💻 C
字号:
/*    This programs aim is to verify the byte ordering system on    on my PC and on ngw100.Source from Unix Network Programming(pg 78)    Copyright (C) 2009  Iban Lopetegui    This program is free software: you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation, either version 3 of the License, or    any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program.  If not, see <http://www.gnu.org/licenses/>.*//*To compilegcc -o byteorder byteorder.cavr32-linux-gcc -o byteorder.elf byteorder.c*/#include <stdio.h>int main (int argc, char **argv){	union{			/*structure that gathers the same value for the short and the char*/		short  s;		char  c[sizeof(short)];	}un;	un.s=0x0102;	if (sizeof(short)==2){		if ((un.c[0]==1)&&(un.c[1]==2))				printf("little endian\n");		else if ((un.c[0]==2)&&(un.c[1]==1))				printf("big endian\n");		else printf("unkown\n");	} else		printf("size of short is %d\n",sizeof(short));			return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -