易截截图软件、单文件、免安装、纯绿色、仅160KB

C/C++——小编谈C语言函数那些事(22)

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1.    setmem函数
setmem函数的功能是存值到存储区,其用法为:void setmem(void *addr, int len, char value);程序实例如下:
#include <stdio.h>
#include <alloc.h>
#include <mem.h>
int main(void)
{
   char *dest;
   dest = calloc(21, sizeof(char));
   setmem(dest, 20, 'c');
   printf("%s\n", dest);
   return 0;
}
 2.   setmode函数
setmode函数的功能是设置打开文件方式,其用法为int setmode(int handle, unsigned mode);程序实例代码如下:
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
int main(void)
{
   int result;
   result = setmode(fileno(stdprn), O_TEXT);
   if (result == -1)
      perror("Mode not available\n");
   else
      printf("Mode successfully switched\n");
   return 0;
}
3.    setpalette函数
setpalette函数的功能是改变调色板的颜色, 其用法为:void far setpalette(int index, int actural_color);程序实例代码如下:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
   int gdriver = DETECT, gmode, errorcode;
   int color, maxcolor, ht;
   int y = 10;
   char msg[80];
   initgraph(&gdriver, &gmode, "");
   errorcode = graphresult();
   if (errorcode != grOk) 
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1);
   }
   maxcolor = getmaxcolor();
   ht = 2 * textheight("W");
&nbs


相关文档:

[随想]C/C++程序员

       刚刚看过这篇《30 years of C》,回想了这几年的学习历程。
      在大学里,我学习的第一门程序设计语言是C,但花时间最多的还是C++。大约五年前,开始啃《 C++编程思想》两卷本,用Dev-cpp在机器练习着书上的一个个例子程序,之后又学习了面向对象编程、STL、模板。凭着 ......

Python 的C语言扩展

操作系统:linux debian 4.0, python版本2.5
s1:安装python2.5-dev。因为Python.h是在dev包中才有。
test@debian:~/test_python_c$ aptitude search python2.5-dev
p python2.5-dev - Header files and a static library for Python.
test@debian:~/test_python_c$ sudo aptitude install python2 ......

C/C++——小编谈C语言函数那些事(17)

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1.    registerbgidriver函数
registerbgidriver函数的功能是登录已连接进来的图形驱动程序代码,其用法为:int registerbgidriver(void(*driver)(void ......

linux c++连接mysql示例

 
 编译和连接程序
  MySQL中有一个特殊的脚本,叫做mysql_config. 它会为你编译MySQL客户端,并连接到MySQL服务器提供有用的信息.你需要使用下面两个选项.
  1. --libs 选项 - 连接MySQL客户端函数库所需要的库和选项.
  $ mysql_config --libs
  2. --cflags 选项 - 使用必要的include文件的选项等等.
......

C标准库函数

函数名: abort
功  能: 异常终止一个进程
用  法: void abort(void);
程序例:
#include <stdio.h>
#include <stdlib.h>
 
int main(void)
{
  printf("Calling abort()\n");
  abort();
  return 0; /* This is never reached */
}
 
 
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号