C/C++——小编谈C语言函数那些事(14)
C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1. normvideo函数
malloc函数的功能是选择正常亮度字符,其用法为:void normvideo(void);程序实例如下:
#include <conio.h>
int main(void)
{
normvideo();
cprintf("NORMAL Intensity Text\r\n");
return 0;
}
2. open函数
open函数的功能是打开一个文件用于读或写,其用法为:int open(char *pathname, int access[, int permiss]); 程序实例代码如下:
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
int main(void)
{
int handle;
char msg[] = "Hello world";
if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
{
perror("Error:");
return 1;
}
write(handle, msg, strlen(msg));
close(handle);
return 0;
}
3. outtextxy函数
outtextxy函数的功能是在指定位置显示一字符串, 其用法为:void far outtextxy(int x, int y, char *textstring);程序实例代码如下:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
initgraph( &gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf
相关文档:
C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1. kbhit函数
kbhit函数是检查当前按下的键,其用法为:int kbhit(void);程序例子如下:
#include <conio.h>
int main(void)
{
c ......
unzip.c
中引用validate.cpp
文件中的函数来进行epub
纠错,产生的问题:
1.
validate.cpp
中使用iostream.h,
但是C
中没有这个文件
,所以产生的错误:
2>
正在编译...
2>unzip.c
2>D:\Program
Files\VC\include\cstdio(25) : error C2143:
语法错误:
缺少“{ ......
VC.NET中的String类是利用Unicode字符集编码来表示文本。Unicode字符集中每个字符(汉字、英文字母)都占2个字节,且其字符串是以2个连续的\0结尾的。
ANSI的ASCII字符集是最常见的字符集,常用于表示txt的文本文件。在ASCII字符集中英文占一个字节,汉字2个字节,且其字符串是以一个\0结尾的。
在利用VC.NET进行混合编程时 ......
第一种理解
比如说你用C++开发了一个DLL库,为了能够让C语言也能够调用你的DLL输出(Export)的函数,你需要用extern "C"来强制编译器不要修改你的
函数名。
通常,在C语言的头文件中经常可以看到类似下面这种形式的代码:
#ifdef __cplusplus
extern "C" {
#endif
/**** some declaration or so *****/
#ifde ......