c语言函数--O

书画小说软件 制作更惬意的读、更舒心的写、更轻松的发布

最全古典小说网 由本软件发布所得

函数名: 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; 
} 
  
  

函数名: outport

功 能: 输出整数到硬件端口中

用 法: void outport(int port, int value);

程序例:

#include <stdio.h> 
#include <dos.h> 
int main(void) 
{ 
   int value = 64; 
   int port = 0; 
   outportb(port, value); 
   printf("Value %d sent to port number %d\n", value, port); 
   return 0; 
} 
  
  

函数名: outportb

功 能: 输出字节到硬件端口中

用 法: void outportb(int port, char byte);

程序例:

#include <stdio.h> 
#include <dos.h> 
int main(void) 
{ 
   int value = 64; 
   int port = 0; 
   outportb(port, value); 
   printf("Value %d sent to port number %d\n", value, port); 
   return 0; 
} 
  
  

函数名: outtext

功 能: 在视区显示一个字符串

用 法: void far outtext(char far *textstring);

程序例:

#include <graphics.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <conio.h> 
int main(void) 
{ 
   /* request auto detection */ 
   int gdriver = DETECT, gmode, errorcode; 
   int midx, midy; 
   /* initialize graphics and local variables */ 
   initgraph(&gdriver, &gmode, ""); 
   /* read result of initialization */ 
   errorcode = graphresult(); 
   if (errorcode != grOk)  /* an error occurred */ 
   { 
      printf("Graphics error: %s\n", grapherrormsg(errorcode)); 
      printf("Press any key to halt:"); 
      getch(); 
      exit(1); /* terminate with an error code */ 
   } 
   midx = getmaxx() / 2; 
   midy = getmaxy() / 2; 
   /* move the C.P. to the center of the screen */ 
   moveto(midx, midy); 
   /* output text starting at the C.P. */ 
   outtext("This "); 
   outtext("is "); 
   outtext("a "); 
   outtext("test."); 
   /* clean up */ 
   getch(); 
   closegraph(); 
   return 0; 
} 
  
  

函数名: 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) 
{ 
   /* request auto detection */ 
   int gdriver = DETECT, gmode, errorcode; 
   int midx, midy; 
   /* initialize graphics and local variables */ 
   initgraph( &gdriver, &gmode, ""); 
   /* read result of initialization */ 
   errorcode = graphresult(); 
   if (errorcode != grOk)  /* an error occurred */ 
   { 
      printf("Graphics error: %s\n", grapherrormsg(errorcode)); 
      printf("Press any key to halt:"); 
      getch(); 
      exit(1); /* terminate with an error code */ 
   } 
   midx = getmaxx() / 2; 
   midy = getmaxy() / 2; 
   /* output text at the center of the screen*/ 
   /* Note: the C.P. doesn‘t get changed.*/ 
   outtextxy(midx, midy, "This is a test."); 
   /* clean up */ 
   getch(); 
   closegraph(); 
   return 0; 
} 
  
  
  
  
 

书画小说软件 制作更惬意的读、更舒心的写、更轻松的发布

最全古典小说网 由本软件发布所得

时间: 2024-08-07 05:59:05

c语言函数--O的相关文章

C#委托与C语言函数指针及函数指针数组

C#委托与C语言函数指针及函数指针数组 在使用C#时总会为委托而感到疑惑,但现在总新温习了一遍C语言后,才真正理解的委托. 其实委托就类似于C/C++里的函数指针,在函数传参时传递的是函数指针,在调用的时候通过指针访问这个函数. 在C语言中函数指针的申明如下: //可以理解为申明一个指着变量 Func ,它的类型是 返回Type(可以为 void )类型的参数,接收 (Type one,Type two,...)类型的//参数(可以不接受参数). Type *Func(Type one,Type

c 语言 函数的整理 百度脑图版本

下面整理一下C语言函数的知识点 :使用百度脑图进行整理,详情请看上传的图片: 版权声明:本文为博主原创文章,未经博主允许不得转载.

汇编1 ----C语言函数1

构造以下C程序并在合适位置插入breakpoints 在Visual Studio 2015 CTP6对其反汇编. 下面来分析 z = add(1, 2); 009C170E 6A 02 push 2 ????int z; ????z = add(1, 2); 009C1710 6A 01 push 1 009C1712 E8 8D FA FF FF call 009C11A4 009C1717 83 C4 08 add esp,8 009C171A 89 45 F8 mov dword ptr

(转)如何编写有多个返回值的C语言函数

1引言    笔者从事C语言教学多年,在教学中学生们常常会问到如何编写具有多个返回值的C语言函数.编写有多个返回值的函数是所有C语言教材里均没有提到的知识点,但在实际教学与应用的过程中我们都有可能会遇到这样的问题.有学生也尝试了不少方法:如把多个需要返回的值作相应的处理后变成一个可以用return语句返回的数据,再在主调函数中拆开返回的数据使之变成几个值:或者把需要返回多个值的一个函数分开几个函数去实现多个值的返回.这些方法虽然最终都能实现返回要求的多个值,但从程序算法的合理性与最优化方面去考虑

Linux汇编GAS调用C语言函数实例

Blum的书上只讲了C语言调用汇编,没讲汇编调用C语言.我自己尝试了下. 最终试验成功了,在此写出与大家分享.期间历经无数错误,无数异常,我不是醉了,而是跪了...好在最后好了. 程序实现一个换值功能,在main.s里定义a=10,b=20,然后调用C语言函数把a,b换值. 新建两个文件分别为main.s的汇编文件,还有pro.c的C语言函数文件. main.s的代码如下: .section .data a: .int 10 b: .int 20 .section .text .globl ma

C语言函数sscanf()的用法 (转载

在我的学习过程中,从文件读取数据是一件很麻烦的事,所幸有sscanf()函数. C语言函数sscanf()的用法 sscanf() - 从一个字符串中读进与指定格式相符的数据. 函数原型: int sscanf( string str, string fmt, mixed var1, mixed var2 ... ); int scanf( const char *format [,argument]... ); 说明: sscanf与scanf类似,都是用于输入的,只是后者以屏幕(stdin)

C语言函数sscanf()的用法(转)

转自:http://www.cnblogs.com/lyq105/archive/2009/11/28/1612677.html C语言函数sscanf()的用法 sscanf() - 从一个字符串中读进与指定格式相符的数据. 函数原型: int sscanf( string str, string fmt, mixed var1, mixed var2 ... ); int scanf( const char *format [,argument]... ); 说明: sscanf与scanf

[整理]C语言函数说明和定义

函数的一般形式是:type-specifier function_name(parameter list) parameter declarations{   body of the function} 1.类型说明符定义了函数中return语句返回值的类型,该返回值可以是任何有效类型.假如没有类型说明符出现,函数返回一个整型值. 当一个函数没有明确说明类型时, C语言的编译程序自动将整型( i n t)作为这个函数的缺省类型,缺省类型适用于很大一部分函数. 当有必要返回其它类型数据时,需要分两

从linux0.11中起动部分代码看汇编调用c语言函数

上一篇分析了c语言的函数调用栈情况,知道了c语言的函数调用机制后,我们来看一下,linux0.11中起动部分的代码是如何从汇编跳入c语言函数的.在LINUX 0.11中的head.s文件中会看到如下一段代码(linux0.11的启动分析部分会在另一部分中再分析,由于此文仅涉及c与汇编代码的问题,). after_page_tables: pushl $0 # These are the parameters to main :-) pushl $0 pushl $0 pushl $L6 # re

借助动态代码生成技术在基于Webkit引擎的HTML5网页JS内调用易语言函数

作者:庄晓立(Liigo) 日期:2015年3月3日夜 原创链接:http://blog.csdn.net/liigo/article/details/44045177 版权所有,转载请注明出处:http://blog.csdn.net/liigo 前两天我协助解决了一个技术问题,在此稍作记录和总结. 具体来说,就是在使用基于Webkit引擎的封装组件wke的过程中,需要把一个易语言函数注册给JavaScript引擎,让它可以在网页里被调用(就像在网页里调用普通JavaScript函数一样).如