#include <stdio.h>
#include <typeinfo>
#include <string>
using namespace std; enum type{FLASH, ONCE}; string Setstr(const char * val)
{
return val;
} #define enumtoCharArr(val) #val
#define enumtoStr(val) Setstr(#val) int main()
{ 
printf("%s\n",typeid(enumtoCharArr(FLASH)).name());//类型
string str = enumtoCharArr(FLASH);
printf("%s\n", str.c_str()); printf("%s\n",typeid(enumtoStr(FLASH)).name());//类型
str = enumtoStr(ONCE);
printf("%s", str.c_str()); getchar();
return 0;
}

  

C++ 把枚举变量的名称,直接当字符串使用方法 字符串化符号 #的更多相关文章

  1. [No0000A4]DOS命令(cmd)批处理:替换字符串、截取字符串、扩充字符串、获取字符串长度

    1.替换字符串,即将某一字符串中的特定字符或字符串替换为给定的字符串.举例说明其功能:========================================= @echo off set a ...

  2. C#字符串处理 及字符串格式化

    本文来自:http://www.cnblogs.com/xuerongli/archive/2013/03/23/2976669.html string字符串是char的集合,而char是Unicod ...

  3. C#常用的字符串处理方法

    1.Replace(替换字符):public string Replace(char oldChar,char newChar);在对象中寻找oldChar,如果寻找到,就用newChar将oldCh ...

  4. C# 截取两个指定字符串中间的字符串列表

    /// <summary> /// 截取两个指定字符串中间的字符串列表(开始和结束两个字符串不能相同!) /// </summary> /// <param name=& ...

  5. 7. python 字符串格式化方法(1)

    7. python 字符串格式化方法(1) 承接上一章节,我们这一节来说说字符串格式化的另一种方法,就是调用format() >>> template='{0},{1} and {2 ...

  6. SQL server 存储过程 C#调用Windows CMD命令并返回输出结果 Mysql删除重复数据保留最小的id C# 取字符串中间文本 取字符串左边 取字符串右边 C# JSON格式数据高级用法

    create proc insertLog@Title nvarchar(50),@Contents nvarchar(max),@UserId int,@CreateTime datetimeasi ...

  7. 【2019-5-26】python:字典、常用字符串处理方法及文件操作

    一.数据类型:字典 1.字典: 1.1定义字典:dict={'key':'value'} 1.2字典与列表相比,字典取值快,可直接找到key 1.3字典是无序的,不能根据顺序取值 1.4多个元素用逗号 ...

  8. C#字符串数组排序 C#排序算法大全 C#字符串比较方法 一个.NET通用JSON解析/构建类的实现(c#) C#处理Json文件 asp.net使用Jquery+iframe传值问题

    C#字符串数组排序   //排序只带字符的数组,不带数字的 private   string[]   aa   ={ "a ", "c ", "b & ...

  9. Gson字符串编码,字符串转换成图片保存,二进制转换成图片保存

    import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.File; import ...

随机推荐

  1. Flink PPT

    杭州第六次 Spark & Flink Meetup 资料分享 https://github.com/397090770/Spark-Flink-Meetup-6-Hangzhou https ...

  2. wireshark抓取本地数据包

    windows系统中,本地向自身发送数据包没有经过真实的网络接口,而是通过环路(loopback interface)接口发送,所以使用基于只能从真实网络接口中抓数据的winpcap是无法抓取本地数据 ...

  3. 【转】Unity3D的LightProbe动态光探头用法介绍

    原创至上,移步请戳:Unity3D的LightProbe动态光探头用法介绍 之前曾经介绍过Unity3D的LightMapping烘焙的用法.单独使用的LightMapping效果很好,但由于只是把光 ...

  4. 【C/C++】关于隐式转换·面试题分析

    题目 以下两个程序片段A 和B ,问哪个能进入循环? 片段A: unsigned short i; unsigned ; ; i < index-; i++) { ........ } 片段B: ...

  5. hive外部表删除遇到的一个坑

    hive外部表删除遇到的一个坑 操作步骤 创建某个表(create external table xxx location xxx) 插入数据(insert xxx select xxx from x ...

  6. Windows下使用MINGW编译ffplay

    之前考虑到需要快速配置编译ffplay,使用了比较暴力的方法,具体可以参考编译ffplay.exe简化版. 这里介绍下相对规范的做法. 前提:已经安装了Windows下GCC开发环境--MINGW+m ...

  7. Spring boot下添加filter

    https://www.cnblogs.com/OnlyCT/p/7133639.html ****************************************************** ...

  8. Centos7.4使用SoftEther搭建V.PN

    参考: https://blog.csdn.net/qq_39591494/article/details/78625394?locationNum=9&fps=1 https://www.b ...

  9. table 中 文字长度大于td宽度,导致文字换行 解决方案

    1.TD不换行 nowrap属性 表格table的td单元格中,文字长了往往会撑开单元格,但是如果table都不够宽了,就换行了好像(不要较真其他情况,我只说会换行的情况).换行后的表格显得乱糟糟,不 ...

  10. LeetCode: Search Insert Position 解题报告

    Search Insert Position Given a sorted array and a target value, return the index if the target is fo ...