C/C++拾遗1

来源:互联网 发布:淘宝我的评价在哪 编辑:程序博客网 时间:2024/05/01 02:40

1. volatile 关键字在 C++ 中的性能和 C 的一样?

作用是一样的,但是其内部实现原理可能不同。

2. scanf 格式化输入是怎么赋值的?

由于scanf输入的数据个数是不定的,从键盘输入的数据会进入缓冲流,然后将输入的数据赋值给scanf的参数。

3. 下面代码的作用?

void func(const char* input, char* output, unsigned int outLen){    int buf[256] = {0};    while( *input )    {        buf[*input++]++;    }    if( output && outLen )    {        int i = 0;        for(i=0; i<256; i++)        {            if( buf[i] )            {                *output++ = (char)i;            }        }        *output = 0;    }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

输入input为“aaabbbccddddd”,得到output为abcd


0 0
原创粉丝点击