茁壮网络C语言开发笔试

1,char *ptr = (char *)malloc(20);

int len = 0,len2 = 0;

 if (ptr)
    {
        strcpy(ptr,"abcdef");

        len = strlen(ptr);
        memcpy(ptr,"abcdefg",7);
        len2 = strlen(ptr);
  }

len = 7   len2 不确定


2,
    unsigned int a = 2;
    int b = -4;
    int c;
    c = ((a+b)>1)+b+++(++a);

    c = 0   a+b的值远远大于1   int型提升为unsigned int


3,

    int a,x;
    for (a = 0,x = 0; a <= 1 && !x++;)
        a++;

    a = 1 ; x = 2


4,

   volatile和const可以同时修饰一个变量

   volatile可以修饰指针

   volatile可以在修饰在多线程访问的变量


5,

   int arr[] = {6,7,8,9,10};
   int *ptr = arr;
   *(ptr++) += 123;
   printf("%d,%d\n",*ptr,*(++ptr));

   8,8


6,

  int i = 3;
    switch(i)
    {
    case 1:
    case 2:
        printf("%d\n",i);
    case 3:
    case 4:
        break;
    default:printf("OK\n");
    }

无输出


7,

    printf("ab\b\bc");

    cb   \b表示退格


8,

    int x = 3;
    do
    {
        printf("%d",x-=2);
    }while (!(--x));

   1 -2


9,

    int key;
    unsigned char data[100] = {0x07,0x31,1};
    key = data[1] & 0x1f<<8|data[2];
    printf("key=0x%08x\n",key);

    0x00000001


10,

   int a;
   void calc_num()
   {
       static int a = 2;
       for (int i; i < 2; i++)
           a+=2;
   }

   int main()
   {
       static int a = 0;
       calc_num();
       printf("%d\n",a);

       return 0;
   }

   0


11,

    int i,j,k,a = 3,b = 2;
    i = (--a == b++)? --a: ++b; j=a++; k=b;


i = 1 j = 1 k = 3


12,

int f(int x)
{
    if (x == 2|| x == 1) return 3;
    return x - f(x - 2);
}

int main()
{
    printf("%d\n",f(6));
    return 0;
}

5


13,

    struct tagValue
   {
       int a,*b;
   }*p;
   int x[] = {1,2};
   int y[] = {3,4};

   int main()
  {
       static struct tagValue c[2] = {5,x,6,y};
       p=c;

printf("%d\n",(p++)->a);
       return 0;
   }

    5



太久没有注重C的细节了,一些不该错的,也错了。是做C方面的开发,挺好的一个工作。

准备不够充分,心态不够好,下一次改进。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值