《C和指针》读书笔记——第一章 快速上手

1.注释代码可以用:

#if 0

  statements

#endif

 

2.参数被声明为const,表明函数将不会修改函数调用者的所传递的这个参数。

 

3.scanf("%d",&columns[num]);//返回存储于参数中的值的个数。

 

4.函数名: strncpy
功  能: 串拷贝
用  法: char *strncpy(char *destin, char *source, int maxlen);
程序例:
#include <stdio.h>
#include <string.h>
int main(void)
{
   char string[10];
   char *str1 = "abcdefghi";
   strncpy(string, str1, 3);
   string[3] = '\0';
   printf("%s\n", string);
   return 0;
}

 

5.函数名: getchar
功  能: 从stdin流中读字符
用  法: int getchar(void);
程序例:
#include <stdio.h>
int main(void)
{
   int c;
   /* Note that getchar reads from stdin and
      is line buffered; this means it will
      not return until you press ENTER. */
   while ((c = getchar()) != '\n')
      printf("%c", c);
   return 0;
}

 

6.字符串常量:

  "Hello"

  在内存里占据6个字节的空间,分别是H,e,l,l,o和NUL。

posted on 2013-09-11 17:33  熊猫酒仙是也  阅读(194)  评论(0编辑  收藏  举报

导航