博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
XDR-变长类型数组-空间管理-log
阅读量:4045 次
发布时间:2019-05-24

本文共 2156 字,大约阅读时间需要 7 分钟。

XDR-变长类型数组-空间管理-log

2014年4月8日23:39:02

.x文件:

enum colors{ 	RED = 2, 	YELLOW = 3, 	BLUE = 5,	GREEN = 0x10};struct lww_int{	int m_nAge;	bool m_bMale;	string m_sName<255>;	colors m_ayColor[2];	int m_naNum<4>;};union lww_union switch(colors clr){case RED:	int m_nAge;case YELLOW:	bool m_bMale;case BLUE:	string m_sName<255>;case GREEN:	colors m_ayColor[2];};
C程序:

#include 
#include
#include "lww.h"//int main()//{// printf("begin\n");//// FILE * pFile = fopen("lww.txt","wb");// XDR XDR;// xdrstdio_create(&XDR,pFile,XDR_ENCODE);//// colors aRED = RED;// colors aYELLOW = YELLOW;// colors aBLUE = BLUE;// colors aGREEN = GREEN;// lww_int aLwwInt;// aLwwInt.m_nAge = 28;// aLwwInt.m_bMale = TRUE;// aLwwInt.m_sName = (char *)"1234";// aLwwInt.m_ayColor[0] = GREEN;// aLwwInt.m_ayColor[1] = BLUE;//// int naInt[2];// naInt[0] = 1;// naInt[1] = 2;// aLwwInt.m_naNum.m_naNum_len = 2;// aLwwInt.m_naNum.m_naNum_val = naInt;//// lww_union aLwwUnion;// aLwwUnion.clr = RED;// aLwwUnion.lww_union_u.m_nAge = 28 * 2;//// xdr_colors(&XDR,&aRED);// xdr_colors(&XDR,&aYELLOW);// xdr_colors(&XDR,&aBLUE);// xdr_colors(&XDR,&aGREEN);// xdr_lww_int(&XDR,&aLwwInt);// xdr_lww_union(&XDR,&aLwwUnion);//// xdr_destroy(&XDR);// fclose(pFile);//// printf("end\n");//// return 0;//}void printColor(colors aColor){ switch(aColor) { case RED: printf("红色\n"); break; case YELLOW: printf("黄色\n"); break; case BLUE: printf("蓝色\n"); break; case GREEN: printf("绿色\n"); break; default: printf("错误色\n"); break; } return;}void printBool(bool_t bPrint){ switch(bPrint) { case TRUE: printf("真\n"); break; case FALSE: printf("假\n"); break; default: printf("错误\n"); break; } return;}lww_int aLwwInt;void writeTLogFile(char * str){ FILE * pFileW = fopen("log.txt","a+"); if(NULL == pFileW) { return; } fprintf(pFileW,"%s\n",str); fclose(pFileW); return;}void writeBLogFile(char * str,int nCount){ FILE * pFileW = fopen("log.txt","ab+"); if(NULL == pFileW) { return; } fwrite(str,1,nCount,pFileW); fclose(pFileW); return;}void writeB2TLogFile(char * str,int nCount){ char sBuffer[400] = {0}; strcpy(sBuffer,"0X"); char * pBuffer = sBuffer + 2; for(int i = 0;i

转载地址:http://unwci.baihongyu.com/

你可能感兴趣的文章
Maven项目版本继承 – 我必须指定父版本?
查看>>
通过C++反射实现C++与任意脚本(lua、js等)的交互(二)
查看>>
利用清华镜像站解决pip超时问题
查看>>
[leetcode BY python]1两数之和
查看>>
微信小程序开发全线记录
查看>>
PTA:一元多项式的加乘运算
查看>>
CCF 分蛋糕
查看>>
解决python2.7中UnicodeEncodeError
查看>>
小谈python 输出
查看>>
Django objects.all()、objects.get()与objects.filter()之间的区别介绍
查看>>
python:如何将excel文件转化成CSV格式
查看>>
机器学习实战之决策树(一)
查看>>
机器学习实战之决策树二
查看>>
[LeetCode By Python]7 Reverse Integer
查看>>
[leetCode By Python] 14. Longest Common Prefix
查看>>
[LeetCode By Python]121. Best Time to Buy and Sell Stock
查看>>
[LeetCode By Python]122. Best Time to Buy and Sell Stock II
查看>>
[LeetCode By Python]125. Valid Palindrome
查看>>
[LeetCode By Python]136. Single Number
查看>>
Android/Linux 内存监视
查看>>