📄 fu.htm
字号:
<HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312"> <META NAME="Author" CONTENT="wdg"> <META NAME="GENERATOR" CONTENT="Mozilla/4.03 [en] (Win95; I) [Netscape]"> <TITLE>fu</TITLE></HEAD><BODY> <BR> <P>函数名: ultoa<BR>功 能: 转换一个无符号长整型数为字符串<BR>用 法: char *ultoa(unsigned long value, char *string, int radix);<BR>程序例:<P>#include <stdlib.h><BR>#include <stdio.h><P>int main( void )<BR>{<BR> unsigned long lnumber = 3123456789L;<BR> char string[25];<P> ultoa(lnumber,string,10);<BR> printf("string = %s unsigned long = %lu\n",string,lnumber);<P> return 0;<BR>}<BR> <BR> <BR> <P>函数名: ungetc<BR>功 能: 把一个字符退回到输入流中<BR>用 法: int ungetc(char c, FILE *stream);<BR>程序例:<P>#include <stdio.h><BR>#include <ctype.h><P>int main( void )<BR>{<BR> int i=0;<BR> char ch;<P> puts("Input an integer followed by a char:");<P> /* read chars until non digit or EOF */<BR> while((ch = getchar()) != EOF && isdigit(ch))<BR> i = 10 * i + ch - 48; /* convert ASCIIinto int value */<P> /* if non digit char was read, push it back into inputbuffer */<BR> if (ch != EOF)<BR> ungetc(ch, stdin);<P> printf("i = %d, next char in buffer = %c\n", i, getchar());<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: ungetch<BR>功 能: 把一个字符退回到键盘缓冲区中<BR>用 法: int ungetch(int c);<BR>程序例:<P>#include <stdio.h><BR>#include <ctype.h><BR>#include <conio.h><P>int main( void )<BR>{<BR> int i=0;<BR> char ch;<P> puts("Input an integer followed by a char:");<P> /* read chars until non digit or EOF */<BR> while((ch = getche()) != EOF && isdigit(ch))<BR> i = 10 * i + ch - 48; /* convert ASCIIinto int value */<P> /* if non digit char was read, push it back into inputbuffer */<BR> if (ch != EOF)<BR> ungetch(ch);<P> printf("\n\ni = %d, next char in buffer = %c\n", i, getch());<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: unixtodos<BR>功 能: 把日期和时间转换成DOS格式<BR>用 法: void unixtodos(long utime, struct date *dateptr,<BR> struct time *timeptr);<BR>程序例:<P>#include <stdio.h><BR>#include <dos.h><P>char *month[] = {"---", "Jan", "Feb", "Mar", "Apr", "May", "Jun",<BR> "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};<P>#define SECONDS_PER_DAY 86400L /* the number of seconds in oneday */<P>struct date dt;<BR>struct time tm;<P>int main(void)<BR>{<BR> unsigned long val;<P>/* get today's date and time */<BR> getdate(&dt);<BR> gettime(&tm);<BR> printf("today is %d %s %d\n", dt.da_day, month[dt.da_mon],dt.da_year);<P>/* convert date and time to unix format (number of seconds since Jan1, 1970 */<BR> val = dostounix(&dt, &tm);<BR>/* subtract 42 days worth of seconds */<BR> val -= (SECONDS_PER_DAY * 42);<P>/* convert back to dos time and date */<BR> unixtodos(val, &dt, &tm);<BR> printf("42 days ago it was %d %s %d\n",<BR> dt.da_day, month[dt.da_mon],dt.da_year);<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: unlink<BR>功 能: 删掉一个文件<BR>用 法: int unlink(char *filename);<BR>程序例:<P>#include <stdio.h><BR>#include <io.h><P>int main(void)<BR>{<BR> FILE *fp = fopen("junk.jnk","w");<BR> int status;<P> fprintf(fp,"junk");<P> status = access("junk.jnk",0);<BR> if (status == 0)<BR> printf("File exists\n");<BR> else<BR> printf("File doesn't exist\n");<P> fclose(fp);<BR> unlink("junk.jnk");<BR> status = access("junk.jnk",0);<BR> if (status == 0)<BR> printf("File exists\n");<BR> else<BR> printf("File doesn't exist\n");<BR> <P> return 0;<BR>}<BR> <BR> <BR> <P>函数名: unlock<BR>功 能: 解除文件共享锁<BR>用 法: int unlock(int handle, long offset, long length);<BR>程序例:<P>#include <io.h><BR>#include <fcntl.h><BR>#include <sys\stat.h><BR>#include <process.h><BR>#include <share.h><BR>#include <stdio.h><P>int main(void)<BR>{<BR> int handle, status;<BR> long length;<P> handle = sopen("c:\\autoexec.bat",O_RDONLY,SH_DENYNO,S_IREAD);<P> if (handle < 0)<BR> {<BR> printf("sopen failed\n");<BR> exit(1);<BR> }<P> length = filelength(handle);<BR> status = lock(handle,0L,length/2);<P> if (status == 0)<BR> printf("lock succeeded\n");<BR> else<BR> printf("lock failed\n");<P> status = unlock(handle,0L,length/2);<P> if (status == 0)<BR> printf("unlock succeeded\n");<BR> else<BR> printf("unlock failed\n");<P> close(handle);<BR> return 0;<BR>}<BR> <P> <A HREF="index.html">返回目录</A><BR></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -