Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÔÚCºÍC£«£«Öаѱê×¼Êä³öÖØ¶¨Ïòµ½Ö¸¶¨Îļþ

C++µÄʵÏÖ
#include<fstream>  
#include <iostream>
using namespace std;
int main()
{  
 ofstream logTest("foo.log");    
 streambuf *oldbuf = cout.rdbuf(logTest.rdbuf());   
  
 cout << "Êä³öµ½±ê×¼Êä³ö£¬µ«Êµ¼ÊÊä³öµ½ÁËfoo.logÎļþÖÐ\n";    
 logTest << "Êä³öµ½Îļþ£¬ËäÈ»½«coutÖØ¶¨Ïòµ½ÁËlog£¬µ«²»Ó°Ïìlog±¾ÉíµÄʹÓÃ\n";   
  
  // »Ö¸´Á÷»º³åÇø    
  cout.rdbuf(oldbuf);
  cout << "Êä³öµ½±ê×¼Êä³ö\n";  
  getchar();
}  
CµÄʵÏÖ
#include <ios>
#include <iostream>
#include <fstream>
//ÈôʹÓðüº¬.hÎļþ·½Ê½Ôò±àÒ뱨´í
using namespace std;
void main()
{
    ofstream ofs("e:\\a.txt");
    streambuf *osb = cout.rdbuf(ofs.rdbuf());
    cout << "to file" << endl;
    cout.rdbuf(osb);
    cout << "to term" << endl;
}
°¡£¬ÕâÑù¶ÔÓÚʵÏÖÀ´Ëµ¿ÉÄܲ»ÊǺÜÍ×£¬¸Ä³ÉÊÖ¶¯Ë¢Ð»º³å²ÅÓÐÓ¦ÓüÛÖµ
#include <stdio.h>
#include <string.h>
void main()
{
    FILE old_stdout;
    FILE *fp = fopen("e:\\a.txt", "w");
    memcpy(&old_stdout, &_iob[1], sizeof(FILE));
    memcpy(&_iob[1], fp, sizeof(FILE));
    
    /*call any functions..*/
    printf("to file");
    /**/
    /*°Ñ»º³åˢе½Îļþ*/
    fflush(stdout);
    memcpy(&_iob[1], &old_st


Ïà¹ØÎĵµ£º

keil C ´ÓÁãѧÆð ½Ìѵ1

#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar num;
void main()
{
 TMOD=0x01;
 TH0=(65536-45872)/256;
 TL0=(65536-45872)%256;
 EA=1;
 ET0=1;
 TR0=1;
 P1=0xFF;
 while(1);
}
void T0_time() interrupt 1
{
  ......

hexdump s 0 n 52 CʵÀý helloworld

[root@localhost test]# hexdump -s 0 -n 52 -C helloworld
00000000  7f 45 4c 46 01 01 01 00  00 00 00 00 00 00 00 00  |.ELF............|
00000010  02 00 03 00 01 00 00 00  10 83 04 08 34 00 00 00  |............4...|
00000020  30 08 00 00 00 00 00 00  34 00 20 ......

C/C++³ÌÐòÔ±±Ø¶ÁµÄÊ®±¾Êé

ÔÚGmail TopLanguage  Group Öп´µ½Ò»ÆªÎÄÕ“C/C++³ÌÐòÔ±±Ø¶ÁµÄÊ®±¾Ê飨ÉÏ£©”£¬´ó¼ÒµÄÌÖÂÛ¶¼ºÜ¼¤Àø£¬´ó¼Ò¶¼¾õµÃÕâÆªÎÄÕÂдµÃºÜ°ô£¬ÎÒÏëÔÚGroupÀïµÄÅóÓѶ¼ÄÜÔÚLookgirlµÄÕâÆªÎÄÕÂÀï»ñÒæ²»ÉÙ£¬Îª´Ë¶·µ¨ÔÚ´Ë×ªÔØ¸ÃÎÄ£¬¹©¸ü¶àÅóÓѽ»Á÷¡¢Ñ§Ï°¡£
C/C++³ÌÐòÔ±±Ø¶ÁµÄÊ®±¾Ê飨ÉÏ£©
Õâ¸öÌâÄ¿´óµÄÓÐЩÀëÆ×£¬Êµ»°Ëµ£ ......

³¹µ×¸ã¶¨CÖ¸Õë

 
תÌû×Ôhttp://teren.itpub.net/post/15914/189516дµÄ·Ç³£ºÃ£¬Í¬Ê±¶Ô×÷Õß´òÆÆÉ°¹øÎʵ½µ×µÄ¾«Éñ³¹µ×ÕÛ·þ
¡¶³¹µ×¸ã¶¨CÖ¸Õë¡·µÚһƪ ±äÁ¿µÄÄÚ´æÊµÖÊ
ÒªÀí½âCÖ¸Õ룬ÎÒÈÏΪһ¶¨ÒªÀí½âCÖГ±äÁ¿”µÄ´æ´¢ÊµÖÊ£¬ËùÒÔÎҾʹӓ±äÁ¿”Õâ¸ö¶«Î÷¿ªÊ¼½²Æð°É£¡
ÏÈÀ´Àí½âÀí½âÄÚ´æ¿Õ¼ä°É£¡Çë¿´ÏÂͼ£º
ÄÚ´æµØ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ