?? 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 ASCII
into int value */
<P> /* if non digit char was read, push it back into input
buffer */
<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 ASCII
into int value */
<P> /* if non digit char was read, push it back into input
buffer */
<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 one
day */
<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 Jan
1, 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 + -