ÔÚ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
Ïà¹ØÎĵµ£º
Ò» £¬ÔõÑùѧϰCÓïÑÔ
ºÜ¶àÈ˶ÔѧϰCÓïÑԸе½ÎÞ´ÓÏÂÊÖ£¬¾³£ÎÊÎÒͬһ¸öÎÊÌ⣺¾¿¾¹ÔõÑùѧϰCÓïÑÔ£¿ÎÒÊÇÒ»¸ö½Ìʦ£¬ÒѾ¿ª·¢Á˺ܶàÄêµÄ³ÌÐò£¬ºÍºÜ¶à¸Õ¸ÕÆð²½µÄÈËÒ»Ñù£¬Ñ§Ï°µÄµÚÒ»¸ö¼ÆËã»úÓïÑÔ¾ÍÊÇCÓïÑÔ¡£¾¹ýÕâЩÄêµÄ¿ª·¢£¬ÎÒÉîÉîµÄÌå»áµ½CÓïÑÔ¶ÔÓÚÒ»¸ö³ÌÐòÉè¼ÆÈËÔ±¶àôµÄÖØÒª£¬Èç¹û²»¶®CÓ ......
#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
{
  ......
×Ô¼ºËѼ¯²¢ÇÒÕûÀí£¬ÓÃÓڲο¼¡£
1.ÍêÕûÁ÷³Ì£º
CÔ´³ÌÐòÍ·Îļþ££>Ô¤±àÒë´¦Àí(cpp)££>±àÒë³ÌÐò±¾Éí££>ÓÅ»¯³ÌÐò££>»ã±à³ÌÐò££>Á´½Ó³ÌÐò-->¿ÉÖ´ÐÐÎļþ
pic from http://edmulroy.portbridge.com/oview.htm
2. cµÄÔ¤´¦Àí
Ô¤±àÒë³ÌÐòËùÍê³ÉµÄ»ù±¾ÉÏÊǶÔÔ´³ÌÐòµÄ& ......
C/S Óë B/S
£±£®Ó²¼þ»·¾³²»Í¬:
¡¡¡¡C/S Ò»°ã½¨Á¢ÔÚרÓõÄÍøÂçÉÏ, С·¶Î§ÀïµÄÍøÂç»·¾³, ¾ÖÓòÍøÖ®¼äÔÙͨ¹ýרÃÅ·þÎñÆ÷ÌṩÁ¬½ÓºÍÊý¾Ý½»»»·þÎñ.
¡¡¡¡B/S ½¨Á¢ÔÚ¹ãÓòÍøÖ®ÉϵÄ, ²»±ØÊÇרÃŵÄÍøÂçÓ²¼þ»·¾³,ÀýÓëµç»°ÉÏÍø, ×âÓÃÉ豸. ÐÅÏ¢×Ô¼º¹ÜÀí. ÓбÈC/S¸üÇ¿µÄÊÊÓ¦·¶Î§, Ò»°ãÖ»ÒªÓвÙ×÷ϵͳºÍä¯ÀÀÆ÷¾ÍÐÐ&n ......
Ò»¸öºÜ¼ò½àµÄËã·¨£º
void Reverse(char s[])
{
for(int i = 0, j = strlen(s) - 1; i < j; ++i, --j) {
char c = s[i];
s[i] = s[j];
s[j] = c;
& ......