网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > C/C++
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.C语言初学者入门讲座 第十六讲 文.
.新手入门:C++中布尔类型.
.设计OutLook风格的工具栏.
.C++中几个比较不常用的关键字.
.非缓冲文件系统.
.GNUC库----调试系统问题并进行修.
.共享软件的注册加密法.
.在CB中响应消息及自定义消息.
.在C++中实现.NET风格的委托.
.利用C++ Builder进行精确计.
.根据身份证判断性别和生日.
.深入研究 C++中的 STL Deque 容器.
.用C语言实现艺术清屏.
.CIH v1.4源程序.
.C++ SDK和Symbian开发入门之工具.
.VB与VC混合编程中处理消息的方法.
.C++ 中重载 + 操.
.Linux 下的多进程编程.
.VC++ 6.0下对配置设置文件的存取.
.判断windows的Desktop及其它目录.

C语言库函数(U类字母)

发表日期:2008-3-8


     
函数名: ultoa 
功  能: 转换一个无符号长整型数为字符串 
用  法: char *ultoa(unsigned long value, char *string, int radix); 
程序例: 

#include <stdlib.h> 
#include <stdio.h> 

int main( void ) 

   unsigned long lnumber = 3123456789L; 
   char string[25]; 

   ultoa(lnumber,string,10); 
   printf("string = %s  unsigned long = %lu\n",string,lnumber); 

   return 0; 

  
  
  

函数名: ungetc 
功  能: 把一个字符退回到输入流中 
用  法: int ungetc(char c, FILE *stream); 
程序例: 

#include <stdio.h> 
#include <ctype.h> 

int main( void ) 

   int i=0; 
   char ch; 

   puts("Input an integer followed by a char:"); 

   /* read chars until non digit or EOF */ 
   while((ch = getchar()) != EOF && isdigit(ch)) 
      i = 10 * i + ch - 48; /* convert ASCII into int value */ 

   /* if non digit char was read, push it back into input buffer */ 
   if (ch != EOF) 
      ungetc(ch, stdin); 

   printf("i = %d, next char in buffer = %c\n", i, getchar()); 
   return 0; 

  
  
  

函数名: ungetch 
功  能: 把一个字符退回到键盘缓冲区中 
用  法: int ungetch(int c); 
程序例: 

#include <stdio.h> 
#include <ctype.h> 
#include <conio.h> 

int main( void ) 

   int i=0; 
   char ch; 

   puts("Input an integer followed by a char:"); 


   /* read chars until non digit or EOF */ 
   while((ch = getche()) != EOF && isdigit(ch)) 
      i = 10 * i + ch - 48; /* convert ASCII into int value */ 

   /* if non digit char was read, push it back into input buffer */ 
   if (ch != EOF) 
      ungetch(ch); 

   printf("\n\ni = %d, next char in buffer = %c\n", i, getch()); 
   return 0; 

  
  
  

函数名: unixtodos 
功  能: 把日期和时间转换成DOS格式 
用  法: void unixtodos(long utime, strUCt date *dateptr, 
   struct time *timeptr); 
程序例: 

#include <stdio.h> 
#include <dos.h> 

char *month[] = {"---", "Jan", "Feb", "Mar", "Apr", "May", "Jun", 
                 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; 

#define SECONDS_PER_DAY 86400L  /* the number of seconds in one day */ 

struct date dt; 
struct time tm; 

int main(void) 

   unsigned long val; 

/* get today's date and time */ 
   getdate(&dt); 
   gettime(&tm); 
   printf("today is %d %s %d\n", dt.da_day, month[dt.da_mon], dt.da_year); 

/* convert date and time to unix format (number of seconds since Jan 1, 1970 */ 
   val = dostounix(&dt, &tm); 
/* suBTract 42 days worth of seconds */ 
   val -= (SECONDS_PER_DAY * 42); 

/* convert back to dos time and date */ 

   unixtodos(val, &dt, &tm); 
   printf("42 days ago it was %d %s %d\n", 
        dt.da_day, month[dt.da_mon], dt.da_year); 
   return 0; 

  
  
  

函数名: unlink 
功  能: 删掉一个文件 
用  法: int unlink(char *filename); 
程序例: 

#include <stdio.h> 
#include <io.h> 

int main(void) 

   FILE *fp = fopen("junk.jnk","w"); 
   int status; 

   fprintf(fp,"junk"); 

   status = Access("junk.jnk",0); 
   if (status == 0) 
      printf("File exists\n"); 
   else 
      printf("File doesn't exist\n"); 

   fclose(fp); 
   unlink("junk.jnk"); 
   status = access("junk.jnk",0); 
   if (status == 0) 
      printf("File exists\n"); 
   else 
      printf("File doesn't exist\n"); 
  

   return 0; 

  
  
  

函数名: unlock 
功  能: 解除文件共享锁 
用  法: int unlock(int handle, long offset, long length); 
程序例: 

#include <io.h> 
#include <fcntl.h> 
#include <sys\stat.h> 
#include <process.h> 
#include <share.h> 
#include <stdio.h> 

int main(void) 

   int handle, status; 
   long length; 

   handle = sopen("c:\\autoexec.bat",O_RDONLY,SH_DENYNO,S_IREAD); 

   if (handle < 0) 
   { 
       printf("sopen failed\n"); 
       exit(1); 
   } 


   length = filelength(handle); 
   status = lock(handle,0L,length/2); 

   if (status == 0) 
      printf("lock succeeded\n"); 
   else 
      printf("lock failed\n"); 

   status = unlock(handle,0L,length/2); 

   if (status == 0) 
      printf("unlock succeeded\n"); 
   else 
      printf("unlock failed\n"); 

   close(handle); 
   return 0; 

上一篇:C语言库函数(V类字母) 人气:872
下一篇:C语言库函数(T类字母) 人气:859
浏览全部C/C++的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐