易截截图软件、单文件、免安装、纯绿色、仅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++——小编谈C语言函数那些事(20)

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1.     setallpallette函数
setallpallette函数的功能是按指定方式改变所有的调色板颜色,其用法为:void far setallpallette(struct palette, fa ......

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

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1.     setfillpatterne函数
setfillpatterne函数的功能是选择用户定义的填充模式,其用法为:void far setfillpattern(char far *upattern, int ......

C/C++中的按值调用与按引用调用

 许多编程语言中的调用函数的两种方法是按值调用(call-by-value)和按引用调用(call-by-reference)。
参数按值调用传递时,生成参数值副本并且传给被调用函数,副本的改变并不影响调用者的原始变量值,这样就可以防止意外的副作用影响开发正确,可靠的系统。按值调用的一个缺点是,如果传递较大的数据项,则复制这个数 ......

linux c++连接mysql示例

 
 编译和连接程序
  MySQL中有一个特殊的脚本,叫做mysql_config. 它会为你编译MySQL客户端,并连接到MySQL服务器提供有用的信息.你需要使用下面两个选项.
  1. --libs 选项 - 连接MySQL客户端函数库所需要的库和选项.
  $ mysql_config --libs
  2. --cflags 选项 - 使用必要的include文件的选项等等.
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号