char str = '1.2.';问题
偶然看到群里老哥问道这个问题
#include <iostream>
using namespace std; int main()
{
char str = '1.2.'; return ;
}
什么?char 还可以赋值字符串的?单引号还可以容纳如此多的字符?
结果
输出 . 就是点
换成其他的如:1.23,输出3
我找汇编看了一下
再结合一下汇编中的大端存大值来看的确是这样。
在内存中,上面字符串中1.28 实际上 8是在低地址端,用byte去取的时候先取到了 8 ,输出。
char str = '1.2.';问题的更多相关文章
- char str[]和char *str的区别
1.http://blog.csdn.net/szchtx/article/details/10396149 char ss[]="C++"; ss[0]='c'; ...
- 【转】char *str 和 char str[]的区别
char str[] = "abcd";定义了一个局部字符数组,返回它的地址肯定是一个已经释放了的空间的地址. 此函数返回的是内部一个局部字符数组str的地址,且函数调用完毕后 此 ...
- char str[] 与 char *str的区别详细解析
char* get_str(void) { char str[] = {"abcd"}; return str; } char str[] = {"abcd"} ...
- vs2017中char* str = "1234asd56";会报错,——const char*类型的值不能用于初始化char*类型的实体
原因: "1234asd56"是常量 ,正确的写法本身就是:const char* str = "1234asd56"; 之所以之前的vs版本可以写成char* ...
- 用C++实现void reverse(char* str)函数,即反转一个null结尾的字符串.
void reverse(char* str) { char *end = str, *begin=str; char temp; while(*end!='\0') { end++; } end-- ...
- 编写函数int count_number_string(char str[])和函数int maxnum_string(char str[])
题目如图: 这里不再赘述 代码: //字符串中统计与查询 //杨鑫 #include <stdio.h> #include <stdlib.h> #include <st ...
- 20130324 LBP CSLBP 全局存储区 局部存储区 char c[]=”hello world”和char *str=”hello world”的区别
1.LBP and CSLBP 2.再论char c[]=”hello world”和char *str=”hello world”的区别 /**************代码1************ ...
- 回文字符串的判断!关于strlen(char * str)函数
#include <stdio.h> #include <string.h> int ishuiw(char * p); int main() { ;//true-false接 ...
- 【gets getline的用法 char[]转化为str】poj 2418
http://poj.org/problem?id=2418 [注意] 1. 输入有空格,用 char str[maxn]; while(gets(str)){ str[]!='\0'; } 或 st ...
随机推荐
- 编译安装MySQL5.6
安装必需的工具 比如cmake.gcc.g++.git CentOS使用下面的命令: yum install cmake gcc g++ git Ubuntu使用下面的命令: apt-get ins ...
- java@ 注解原理与使用
Java反射 java反射机制的定义: 在运行转态时(动态的)时. 对于任意一个类,都能够知道这个类的所有属性和方法 对于任意一个对象,都能够知道调用它的任意属性和方法 Class对象 java中用对 ...
- LeetCode_172. Factorial Trailing Zeroes
172. Factorial Trailing Zeroes Easy Given an integer n, return the number of trailing zeroes in n!. ...
- LeetCode_122. Best Time to Buy and Sell Stock II
122. Best Time to Buy and Sell Stock II Easy Say you have an array for which the ith element is the ...
- iOS笔试题04
1. Object-C有多继承吗?没有的话用什么代替? 1> OC是单继承,没有多继承 2> 有时可以用分类category和协议protocol来代替多继承 2. Object-C有私 ...
- iOS技术面试08:其他
1 客户端安全性处理方式? 1> 网络数据传输(敏感数据[账号\密码\消费数据\银行卡账号], 不能明文发送) 2> 协议的问题(自定义协议, 游戏代练) 3> 本地文件存储(游戏的 ...
- springmvc+mybatis多数据源配置,AOP注解动态切换数据源
springmvc与springboot没多大区别,springboot一个jar包配置几乎包含了所有springmvc,也不需要繁琐的xml配置,springmvc需要配置多种jar包,需要繁琐的x ...
- 慕课零基础学java语言翁恺老师——第一周编程题
温度转换(5分) 题目内容: 写一个将华氏温度转换成摄氏温度的程序,转换的公式是: °F = (9/5)*°C + 32 其中C表示摄氏温度,F表示华氏温度. 程序的输入是一个整数,表示华氏温度.输出 ...
- 【leetcode算法-简单】38. 报数
[题目描述] 报数序列是一个整数序列,按照其中的整数的顺序进行报数,得到下一个数.其前五项如下: 1. 12. 113. 214. 12115. 1112211 被读作 "one 1&qu ...
- CNN-1: LeNet-5 卷积神经网络模型
1.LeNet-5模型简介 LeNet-5 模型是 Yann LeCun 教授于 1998 年在论文 Gradient-based learning applied to document ...