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. 关于phpcms中mysql和mysqli的区别

    用phpcms开发一个考试成绩查询的小模块,用电脑上以前下载的phpcms版本为框架开发,一切顺利.想着下载一个最新版本,以后也免了升级的麻烦.于是,下载好,然后把模块目录.model数据库连接文件. ...

  2. git中的版本库,暂存区和工作区

  3. iOS开发——UI进阶篇(十一)应用沙盒,归档,解档,偏好设置,plist存储,NSData,自定义对象归档解档

    1.iOS应用数据存储的常用方式XML属性列表(plist)归档Preference(偏好设置)NSKeyedArchiver归档(NSCoding)SQLite3 Core Data 2.应用沙盒每 ...

  4. 五款最佳Linux下载管理器推荐

    导读 新的Linux用户从Windows转换过来时面临的困难之一就是,找到一款优秀的下载管理器.如果你是或曾经是Windows用户,可能熟悉互联网下载管理器(IDM).下载加速器Plus(DAP)之类 ...

  5. leetcode 32. Longest Valid Parentheses

    Given a string containing just the characters '(' and ')', find the length of the longest valid (wel ...

  6. 移动前端头部mete

    原文链接:http://caibaojian.com/mobile-meta.html//code from http://caibaojian.com/mobile-meta.html<!DO ...

  7. js之DOM和事件

    DOM 查找 直接查找 var obj = document.getElementById('i1') 间接查找 文件内容操作: innerText 仅文本 innerHTML 全内容 value i ...

  8. Majority Number I & || && |||

    Majority Number Given an array of integers, the majority number is the number that occurs more than ...

  9. JQ引用

    <script type="text/javascript" src="http://files.cnblogs.com/914556495wxkj/jquery- ...

  10. Windows下查看局域网内某台计算机的MAC地址

    我们知道在局域网中,在Windows下,查看局域网内其他主机的ip和对应mac地址的命令是: arp -a 这样可以看到ip和mac地址的对应关系,还是比较方便的 但是有些时候使用arp命令并不能列出 ...