1.int a[][4]={0,0};与int a[3][4] = {0};

元素不够的就以位模式初始化为0

a[第一维][第二维] 的大小,也就是最多存几个

int a[][3]={1,2,3,4,5,6,7,8};实际上等于
int a[][3]={ {1,2,3}, {4,5,6}, {7,8} };
有3个一维元素,所以一维大小为3

测试代码:
 int main(void) {
     ][] = {};
     ; i < ; ++i) {
         ; j < ; ++j) {
             printf("%d ", a[i][j]);
             ) printf("\n");
         }
     }
     ;
 }
2.int k=10;
while(k=0) k=k-1;
则循环体语句一次也不执行
while中k=0,则while(0)判断为0后不再执行下面的语句
3.t=0; while(printf("*")) { t++; if(t>3)break; } 这段程序可执行几次 (4次)

int printf(const char *format, ...);

Upon successful return, these functions return the number of characters
printed (excluding the null byte used to end output to strings).

 4.内存操作:将指针unsigned char* ptr的内容向后移动4个字节

*(ptr+4)=*ptr;

 #include <iostream>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <vector>
 #include <time.h>
 using namespace std;
 #define debug(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl

 int main(void) {
     ;
     unsigned char* ptr=(unsigned char *)&i;
     ; j < ; ++j) {
         printf("%#x %#x\n", &i+j, ptr[j]);
     }
     *(ptr+) = *ptr;
     ; j < ; ++j) {
         printf("%#x %#x\n", &i+j, ptr[j]);
     }
     ;
 }

5.将无符号变量unsigned int val进行字节序颠倒

  //<< > &
     //unsigned int val = 0xff000000;
     unsigned int val = 0xff;
     //val = ((val&0x000000ff)<<24)|((val&0x0000ff00)<<8) |( (val&0x00ff0000)>>8)| ((val&0xff000000)>>24);
     val = ((val&)|((val&) |( (val&)| (val>>);
     printf("%#x\n", val);
 6.字符串逆转:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <time.h>
using namespace std;
#define debug(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl

int main(void)
{
    char *src = "hello,world";
    char *dest = NULL;
    int len = strlen(src);
    dest = ();    //要为\0分配一个空间
    char *d = dest;
    ];    //指向最后一个字符
    )
    {
        *d++ = *s--;
        *d = ;        //尾部要加上\0
    }
    cout << dest << endl;
    free(dest);        //使用完,应当释放空间,以免造成内存泄露
    ;

}

7.编写strcpy函数(10分)  已知strcpy函数的原型是  char *strcpy(char *strDest, const char *strSrc);   其中strDest是目的字符串,strSrc是源字符串。

(1)不调用C++/C的字符串库函数,请编写函数 strcpy

 char *strcpyx(char *strDest, const char *strSrc){
     assert((strDest!=NULL) && (strSrc !=NULL));//2分
     char *address = strDest;// 2分
     while( (*strDest++ = *strSrc++) != '\0')NULL;//2分
     return address;// 2分
 }

(2)strcpy能把strSrc的内容复制到strDest,为什么还要char * 类型的返回值?
答:为了实现链式表达式。 // 2分
例如 int length = strlen( strcpy( strDest, "hello world") );

 

c_test的更多相关文章

  1. 因为没用过,所以没想过的--goto

    今天读了读 Rui Maciel 大神写的 mjson parser,mjson 解析器是一个使用 ISO C 实现的小型 JSON 解析器.嵌入式项目中使用到了该解析器,随即拿出来看看. 看到如下代 ...

  2. 也说python的类--基于python3.5

    在面向对象的语言中,除了方法.对象,剩下的一大重点就是类了,从意义上来讲,类就是对具有相同行为对象的归纳.当一个或多个对象有相同属性.方法等共同特征的时候,我们就可以把它归纳到同一个类当中.在使用上来 ...

  3. ORACLE NUMBER类型Scale为0引发的问题

    今天遇到了一个很有意思的NUMBER类型Scale引发的问题,我用一个简单的测试用例来展示一下这个案例.假如有个TEST的表,有个字段类型为NUMBER,我插入下面两条数据 CREATE TABLE ...

  4. python面向对象基础

    面向对象基础 1. 简述 编程方式: 面向过程: 根据代码在脚本的堆叠顺序,从上到下依次执行 函数式编程:将相同功能的代码封装到函数中,直接调用即可,减少代码重复性 面向对象:对函数进行分类和封装,将 ...

  5. c程序辨别系统是64位 or 32位

    #include <stdio.h> int main(void) { int i = 0x80000000; ){ printf("i = %d\n", i); pr ...

  6. php写插件

    1.写在最前 随着互联网飞速发展,lamp架构的流行,php支持的扩展也越来越多,这样直接促进了php的发展. 但是php也有脚本语言不可避免的问题,性能比例如C等编译型语言相差甚多,所以在考虑性能问 ...

  7. 【系统移植】Android系统移植

    $ . .. Device     . SimulatorWhich would you like] Build type choices are. release     . debugWhich ...

  8. python 将数据随机分为训练集和测试集

    # -*- coding: utf-8 -*- """ Created on Tue Jun 23 15:24:19 2015 @author: hd "&qu ...

  9. #ifdef _cplusplus (转)

    原文不可考,转载链接:http://blog.csdn.net/owldestiny/article/details/5772916 有发现原文的请告知,我会及时更新. 时常在cpp的代码之中看到这样 ...

随机推荐

  1. CentOS 6.5 zabbix 3.0.4 监控MySQL性能

    安装mysql [root@test3 /]# yum -y install mysql mysql-server 初始化数据库 [root@test3 /]# /etc/init.d/mysqld ...

  2. CentOS 6.5 zabbix 3.0.4 SendEmail报警

    官方介绍:http://caspian.dotconf.net/menu/Software/SendEmail/ 1.sendEmail部署 下载安装包到本地.解压 [root@localhost S ...

  3. webpack 教程 那些事儿01-webpack是什么

    文章目录 1. 为什么引入webpack? 2. webpack到底是什么? 3. webpack的工作流程理念 4. webpack的使用 4.1. install webpack 5. 分享源码d ...

  4. JAVA设计模式 之 策略模式

    一. 定义 设计模式定义了算法族,分别封装起来,让他们之间可以互相替代,此模式让算法的变化独立于使用算法的客户(该定义来自于Head First 设计模式). 二. 应用场景 当我们在应用程序中完成一 ...

  5. sqlserver2008清日志

    use [DB Name] Select NAME,size From sys.database_files GO ALTER DATABASE [DB Name] SET RECOVERY SIMP ...

  6. Reflow(渲染)和Repaint(重绘)

    Reflow(渲染):对于DOM结构中的各个元素都有自己的盒模型,浏览器根据各种样式(浏览器的.开发人员定义的等)来计算,并根据计算结果将元素放到它该出现的位置,这个过程称之为reflow. refl ...

  7. iOS 不规则的ImageView

    http://blog.csdn.net/kevinpake/article/details/41205715 我们在做iOS开发的时候,往往需要实现不规则形状的头像,如: 那如何去实现? 通常图片都 ...

  8. jquery版悬浮模块demo

    在做在线客服时,代码就是按照该模块命名.现在,我要添加一个返回主页的功能,我觉得再复制一遍之前的代码,那个量有点多,如果我再添加一个功能,那个量会很多……现在我用创建对象字面量的方式来创建(其实我还想 ...

  9. r-cnn学习系列(三):从r-cnn到faster r-cnn

    把r-cnn系列总结下,让整个流程更清晰. 整个系列是从r-cnn至spp-net到fast r-cnn再到faster r-cnn.  RCNN 输入图像,使用selective search来构造 ...

  10. 2016年11月19日--连接查询,变量、if else、while

    连接查询:通过连接运算符可以实现多个表查询.连接是关系数据库模型的主要特点,也是它区别于其它类型数据库管理系统的一个标志. 常用的两个链接运算符: 1.join   on 2.union     在关 ...