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

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

 C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1.       parsfnm函数
 
parsfnm函数的功能是分析文件名,其用法为:char *parsfnm (char *cmdline, struct fcb *fcbptr, int option);程序实例如下:
#include <process.h>
#include <string.h>
#include <stdio.h>
#include <dos.h>
int main(void)
{
   char line[80];
   struct fcb blk;
   printf("Enter drive and file name (no path - ie. a:file.dat)\n");
   gets(line);
   if (parsfnm(line, &blk, 1) == NULL)
      printf("Error in parsfm call\n");
   else
      printf("Drive #%d  Name: %11s\n", blk.fcb_drive, blk.fcb_name);
   return 0;
}
2.      peek函数
 
peek函数的功能是检查存储单元,其用法为:int peek(int segment, unsigned offset);程序实例代码如下:
#include <stdio.h>
#include <conio.h>
#include <dos.h>
int main(void)
{
   int value = 0;
   printf("The current status of your keyboard is:\n");
   value = peek(0x0040, 0x0017);
   if (value & 1)
      printf("Right shift on\n");
   else
      printf("Right shift off\n");
   if (value & 2)
      printf("Left shift on\n");
   else
      printf("Left shift off\n");
   if (value & 4)
      printf("Control key on\n");
   else
      printf("Control key off\n");
   if (value & 8)
      printf("Alt key on\n");
   else
      printf("Alt key off\n");
   if (value & 16)
  &nb


相关文档:

C文件中引用CPP文件时的问题


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:
语法错误:
缺少“{ ......

C和C++混合编程(__cplusplus使用)


第一种理解
比如说你用C++开发了一个DLL库,为了能够让C语言也能够调用你的DLL输出(Export)的函数,你需要用extern "C"来强制编译器不要修改你的
函数名。
通常,在C语言的头文件中经常可以看到类似下面这种形式的代码:
#ifdef __cplusplus
extern "C" {
#endif
/**** some declaration or so *****/
#ifde ......

用C写的读取代码行数。

今天无事,在论坛上一直看贴子,很少动手实践,今天试着写了一个读取源程序代码行数的例子:
现在的代码如下,可能还有不完善的地方,以后再改进:
#include <stdio.h>
#define CHARCOUNT 255
#define CON 6 /*单行注释最少的时候*/
int realLength = 0;
/*
* function name: strCount
* function : count ......

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

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1.       malloc函数
malloc函数的功能是内存分配函数,其用法为:void *malloc(unsigned size);程序实例如下:
#include <stdio.h>
#i ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号