´Óprintf()̸c/c++Öпɱä²ÎÊýº¯ÊýµÄʵÏÖ
´Óprintf̸¿É±ä²ÎÊýº¯ÊýµÄʵÏÖ ×ªÌù
ÔÎÄ×÷ÕߣºÈÖÑÇÐÂ
ÕªÒª£ºÒ»Ö±ÒÔÀ´¶¼¾õµÃprintfËƺõÊÇcÓïÑÔ¿âÖй¦ÄÜ×îÇ¿´óµÄº¯ÊýÖ®Ò»£¬²»½öÒòΪËüÄܸñʽ»¯Êä³ö£¬¸üÔÚÓÚËüµÄ²ÎÊý¸öÊýûÓÐÏÞÖÆ£¬Òª¼¸¸ö¾Í¸ø¼¸¸ö£¬À´Õß²»¾Ü¡£printfÕâÖÖ¶Ô²ÎÊý¸öÊýºÍ²ÎÊýÀàÐ͵ÄÇ¿´óÊÊÓ¦ÐÔ£¬ÈÃÈ˲úÉúÁ˶ÔËü½øÐÐ̽Ë÷µÄŨºñÐËȤ¡£
¹Ø¼ü×Ö£ºprintf, ¿É±ä²ÎÊý
1. ʹÓÃÇéÐÎ
int a =10;
double b = 20.0;
char *str = "Hello world";
printf("begin print\n");
printf("a=%d, b=%.3f, str=%s\n", a, b, str);
...
¡¡¡¡´ÓprintfµÄʹÓÃÇé¿öÀ´¿´£¬ÎÒÃDz»ÄÑ·¢ÏÖÒ»¸ö¹æÂÉ£¬¾ÍÊÇÎÞÂÛÆä¿É±äµÄ²ÎÊýÓжàÉÙ¸ö£¬printfµÄµÚÒ»¸ö²ÎÊý×ÜÊÇÒ»¸ö×Ö·û´®¡£¶øÕýÊÇÕâµÚÒ»¸ö²ÎÊý£¬Ê¹µÃËü¿ÉÒÔÈ·ÈϺóÃ滹ÓÐÓжàÉÙ¸ö²ÎÊýβËæ¡£¶øβËæµÄÿ¸ö²ÎÊýÕ¼ÓõÄÕ»¿Õ¼ä´óСÓÖÊÇͨ¹ýµÚÒ»¸ö¸ñʽ×Ö·û´®È·¶¨µÄ¡£È»¶øprintfµ½µ×ÊÇÔõÑùÈ¡µÚÒ»¸ö²ÎÊýºóÃæµÄ²ÎÊýÖµµÄÄØ£¬Çë¿´ÈçÏ´úÂë
2. printf º¯ÊýµÄʵÏÖ
//acenv.h
typedef char *va_list;
#define _AUPBND (sizeof (acpi_native_int) - 1)
#define _ADNBND (sizeof (acpi_native_int) - 1)
#define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))
#define va_arg(ap, T) (*(T *)(((ap) += (_bnd (T, _AUPBND))) - (_bnd (T,_ADNBND))))
#define va_end(ap) (void) 0
#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND))))
//start.c
static char sprint_buf[1024];
int printf(char *fmt, ...)
{
va_list args;
int n;
va_start(args, fmt);
n = vsprintf(sprint_buf, fmt, args);
va_end(args);
write(stdout, sprint_buf, n);
return n;
}
//unistd.h
stati
Ïà¹ØÎĵµ£º
/*****************************************************
Îļþ:main.c
¹¦ÄÜ:²âÊÔÔËÐÐʱ¼ä(C)!
×÷Õß:chinayaosir QQ:44633197
¹¤¾ß:VC++6.0±àÒëOK!
ÈÕÆÚ:11/28/2009
´úÂëĿ¼:
//1.°üº¬Í·Îļþ
//2.mainÖ÷³ÌÐò
//²»Í¬µÄË㷨ʵÏÖµÄÐÔÄÜ,ÔËÐÐʱ¼äÏà²î·Ç³£´óµÄ!
ÐÞ¸ÄÁбí:
***************** ......
NetBeansÌṩÁËÒ»¸öºÜºÃµÄC/C++¿ª·¢»·¾³£¬Õâ¸ö¿ª·¢»·¾³ÊÇ»ùÓÚGCC±àÒëÆ÷£¬ËùÒÔÔÚWindowsÉÏÊÇÐèҪͨ¹ýÅäÖòÅÄÜʹÓÃNetBeansµÄC/C++ƽ̨¡£
ÅäÖÃÖ»ÓÐÈý²½£º
1¡¢ÏÂÔØMinGWºÍMSYS
2¡¢ÅäÖÃMSYSµÄ»·¾³±äÁ¿
3¡¢ÔÚNetBeansÖÐÅäÖÃC/C++ƽ̨
-------------------------
µÚÒ»²½£ºÏÂÔØMinGWºÍMSYS
Ê×ÏÈÐèÒªÏÂÔØMinGWºÍMSYS£¬MinGWÊ ......
µÚһƪÎÄÕÂÖÕÓÚÂä±ÊÁË£¬±¾ÎĽ«´Ó˼¿¼µÄ½Ç¶ÈÈ¥ÖØÐÂÈÏʶһÏÂHelloworld¡£ÔÚÀý×ÓÖ®ºó»áÌá³ö²»Í¬µÄÎÊÌ⣬Òýµ¼´ó¼Òȥ˼¿¼Ã¿Ò»¾äÄËÖÁÿ¸öϸ½Ú¡£Í¬Ê±Ï£ÍûÄܹ»Èôó¼ÒÒÔºóÄܹ»ÒÔ²»¶Ï˼¿¼²»¶ÏÌáÎʵķ½Ê½È¥¿´´ý×Ô¼ºµÄ³ÌÐò¡£ÎÒÏàÐÅ´ó¼Ò»á·¢ÏֺܶàеĶ«Î÷£¬ºÃÁËÇÐÈëÕýÌâ¡£
ÎÒÃÇÿѧһÖÖеÄÓïÑÔ»ù±¾¶¼»á´Óhelloworld¿ªÊ¼£¬»ù±¾Ã¿ÖÖÓïÑÔ ......
[ZT]×Ô¼º¶¯ÊÖÓà C À©Õ¹ PHP
ÒýÑÔ:
ÓиÐÓÚ´ó¶àÊýÈËÈÏΪ PHP Ö»ÊÇÒ»ÖÖÈõÀàÐÍ£¬Ö»ÄÜ×öСÐÍwebÓ¦ÓõĽű¾ÓïÑÔ¡£ ÓëÄ¿Ç°µÄJava, .Netƽ̨ÓÐÒ»¶¨µÄ²î¾à£¬ËùÒÔ¾ö¶¨Ð´Ò»Ð© PHP µÄÀ©Õ¹·½·¨ÎÄÕ£¬ÎÒÏàÐÅ
ÎÒÃÇPHPERÃÇͨ¹ý×Ô¼º¶¯ÊÖдÉÌÒµÀ©Õ¹£¬Ò»¶¨Äܹ¹½¨³öÇ¿´óµÄ£¬¼«ËÙµÄWebÓ¦Óã¬ÒòΪÀ©Õ¹±¾Éí¾ÍÊDZàÒëÐÍÓïÑÔ±àдµÄ(c ......
#1Â¥ µÃ·Ö£º0»Ø¸´ÓÚ£º2009-12-26 15:37:26
¼ÓÃÜÓкܶàÖÖ·½·¨.ͬʱC#Ò²ÌṩÁ˺ܶà¼ÓÃÜ·½·¨.ÄãÐèÒª¼ÓÃܺͽâÃÜÔÚ¼ÓÃÜËã·¨ÉÏÐèҪʹÓöԳƼÓÃÜ.ÎÒ¸øÄãÌṩһ¸ö¼òµ¥µÄËã·¨.ÔÚ±£´æµÄʱºò¿ÉÒÔʹÓöþ½øÖƵķ½Ê½À´±£´æµ½Îļþ.
C# code
using System;
using System.IO;
using System.Text;
using System.Security.Cryptography ......