字符串的两种不同风格: C++风格和C风格
这个提法有点怪异,但还是常常出现:
char *p = "abcd";
和
string str = "abcdefg";
第一个叫做C风格的字符串,原因是有null作为结尾; 第二个为C++风格的, 不是以null结尾.
实质上: C风格的字符串是:
char[] pArr = {'a', 'b', 'c', 'd', '\0'};
这样决定了处理方式的不同
相关文档:
Delphi 与 C/C++ 数据类型对照表
Delphi数据类型C/C++
ShorInt
8位有符号整数
char
Byte
8位无符号整数
BYTE,unsigned short
SmallInt
16位有符号整数
short
Word
16位无符号整数
unsigned short
Integer,LongInt
32位有符号整数
int,long
Cardinal,LongWord/DWORD
32位无符号整数
unsigned long
Int6 ......
最近在开发中,对常量参与运算时候,出了几个问题,特记录如下:
1.例子一(KEIL-51)
unsigned char recsum,xorsum;
recsum == 0xFF;
xorsum == 0x00;
if(recsum != (xorsum-1)) //这时候不相等
if(recsum != (unsigned ch ......
格式:文件指针名=fopen(文件名,使用文件方式)
参数:
文件名 意义
"C:\\TC\\qwe.txt" 文件C:\TC\qwe.txt
"qwe.txt" 和程序在同一目录下的qwe.txt
文件使用方式 意 义
“rt” 只读打开一个文本文件,只允许读数据
“wt” 只写打开或建立一个文本文件,只允许写数据 ......
1、安装基础类库和man帮助文档等
sudo apt-get install build-essential sun-java6-jdk debian-keyring g++-multilib g++-4.2-multilib gcc-4.2-doc libstdc++6-4.3-dbg equivs glibc-doc manpages-dev libstdc++6-4.3-doc diff-doc binfmt-support sun-java6-source manpages manpages-posix manpages-posix- ......
华为C/C++笔试题2 收藏
1. 某32位系统下, C++程序,请计算sizeof 的值
#include <stdio.h>
#include <malloc.h>
void Foo ( char str[100] )
{
printf("sizeof(str)=%d \n", sizeof(str) );//此处使用char *str与char str[100]是一样的,char str[100]不指明大小(char str[]) ......