易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : c

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, uns ......

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, uns ......

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

 C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1.      qsort函数
qsort函数的功能是使用快速排序例程进行排序,其用法为:void qsort(void *base, int nelem, int width, int (*fcmp)());程序实例如下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int sort_function( const void *a, const void *b);
char list[5][4] = { "cat", "car", "cab", "cap", "can" };
 
int main(void)
{
   int  x;
   qsort((void *)list, 5, sizeof(list[0]), sort_function);
   for (x = 0; x < 5; x++)
      printf("%s\n", list[x]);
   return 0;
}
int sort_function( const void *a, const void *b)
{
   return( strcmp(a,b) );
}
 
2.      putw函数
putw函数的功能是把一字符或字送到流中,其用法为int putw(int w, FILE *stream);程序实例代码如下:
#include ......

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

 C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1.      qsort函数
qsort函数的功能是使用快速排序例程进行排序,其用法为:void qsort(void *base, int nelem, int width, int (*fcmp)());程序实例如下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int sort_function( const void *a, const void *b);
char list[5][4] = { "cat", "car", "cab", "cap", "can" };
 
int main(void)
{
   int  x;
   qsort((void *)list, 5, sizeof(list[0]), sort_function);
   for (x = 0; x < 5; x++)
      printf("%s\n", list[x]);
   return 0;
}
int sort_function( const void *a, const void *b)
{
   return( strcmp(a,b) );
}
 
2.      putw函数
putw函数的功能是把一字符或字送到流中,其用法为int putw(int w, FILE *stream);程序实例代码如下:
#include ......

C判断文件存在

 用函数access,头文件是io.h,原型:
  
int   access(const   char   *filename,   int   amode);
amode参数为0时表示检查文件的存在性,如果文件存在,返回0,不存在,返回-1。
这个函数还可以检查其它文件属性:
06     检查读写权限
04     检查读权限
02     检查写权限
01     检查执行权限
00     检查文件的存在性
在UNIX和VC下实验成功。
好处是 fopen(..,"r")不好,当无读权限时一不行了。
而这个就算这个文件没有读权限,也可以判断这个文件存在于否
存在返回0,不存在返回-1
#include <stdio.h>
int main()
{
      
printf ("%d",access("111",0));
} ......

混凝土强度评定系统1.1 c代码

#define NULL 0
#define LEN 10
#define OK printf("\n此组数据合格。\n")
#define NO printf("\n此组数据不合格!\n")
#define CN printf("\n%30c 伟成工作室荣誉出品 %c\n",17,16)
#include "stdlib.h"
#include "math.h"
static float min,ave;       
float *zwfloat(void)        
{
    float *array,value;
    int size,count;
    size=LEN;
    array=malloc((size+1)*sizeof(float));
    if (array==NULL) return NULL;
    count=0;
    while (scanf("%f",&value),value!=0)   
    {
     if(value<0) continue;
        count+=1;
        if (count>size)      
        {
        &nbs ......

C/C++多种方法获取文件大小

#include <iostream>
#include <io.h>
#include <sys\stat.h>
#include <afx.h>
#define _AFXDLL
using namespace std;
void main()
{
    // 此文件在工程打开状态下为不可访问
    char* filepath = "..\\test.ncb";
    // 方法一
    struct _stat info;
    _stat(filepath, &info);
    int size = info.st_size;
    cout<<size<<endl;
    // 方法二
    FILE* file = fopen(filepath, "rb");
    if (file)
    {
        int size = filelength(fileno(file));
        cout<<size<<endl;
     ......

C/C++多种方法获取文件大小

#include <iostream>
#include <io.h>
#include <sys\stat.h>
#include <afx.h>
#define _AFXDLL
using namespace std;
void main()
{
    // 此文件在工程打开状态下为不可访问
    char* filepath = "..\\test.ncb";
    // 方法一
    struct _stat info;
    _stat(filepath, &info);
    int size = info.st_size;
    cout<<size<<endl;
    // 方法二
    FILE* file = fopen(filepath, "rb");
    if (file)
    {
        int size = filelength(fileno(file));
        cout<<size<<endl;
     ......

C可变参数函数 实现

 C函数要在程序中用到以下这些宏:
void va_start( va_list arg_ptr, prev_param );
type va_arg( va_list arg_ptr, type );
void va_end( va_list arg_ptr );
va_list:用来保存宏va_start、va_arg和va_end所需信息的一种类型。为了访问变长参数列表中的参数,必须声明
             va_list类型的一个对象       定义: typedef char *  va_list;
va_start:访问变长参数列表中的参数之前使用的宏,它初始化用va_list声明的对象,初始化结果供宏va_arg和
               va_end使用;
va_arg: 展开成一个表达式的宏,该表达式具有变长参数列表中下一个参数的值和类型。每次调用va_arg都会修改
              用va_list声明的对象,从而使该对象指向参数列表中的下一个参数;
va_end:该宏使程序能够从变长参数列表用宏va_start引用的函数中正常返回。
va在这里是variable-argument(可变参数)的意思.
这 ......
总记录数:2015; 总页数:336; 每页6 条; 首页 上一页 [237] [238] [239] [240] 241 [242] [243] [244] [245] [246]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号