字符串的两种不同风格: C++风格和C风格
这个提法有点怪异,但还是常常出现:
char *p = "abcd";
和
string str = "abcdefg";
第一个叫做C风格的字符串,原因是有null作为结尾; 第二个为C++风格的, 不是以null结尾.
实质上: C风格的字符串是:
char[] pArr = {'a', 'b', 'c', 'd', '\0'};
这样决定了处理方式的不同
相关文档:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include ".\sqlite3_lib\sqlite3.h"
static int _callback_exec(void * notused,int argc, char ** argv, char ** aszColName)
{
int i;
for ( i=0; i<argc; i++ )
......
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 ......
(转)C++中extern “C”含义深层探索
1.引言
C++语言的创建初衷是“a better C”,但是这并不意味着C++中类似C语言的全局变量和函数所采用的编译和连接方式与C语言完全相同。作为一种欲与C兼容的语言,C++保留了一部分过程式语言的特点(被世人称为“不彻底地面向对象&rdquo ......
华为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[]) ......