最近在sina看nba的文字直播的时候,对网站右下角的那一个聊天窗口产生兴趣,就决定自己也做一个。
上网查查资料,这样的聊天室无非就是用户输入数据传到服务器保存,然后用户页面再实时地从数据库取出数据,显示在页面上,即可完成一次聊天操作。
首先我定义了一个xml文件,用于保存用户的聊天数据,
<?xml version="1.0" encoding="utf-8"?>
<Messages>
<Message>
<users>crazyluo</users>
<data>ceshide</data>
<sendtime>23:25</sendtime>
<sendto>me</sendto>
</Message>
</Messages>
users保存发送信息的用户,data是发送的数据,sendtime是发送的时间,sendto是发送的对象
然后创建一个聊天的页面,页面代码大致是如下:
<div id="main">
<div id="msg"></div>
<div id="div1">
<textarea id="text" style="width:200px;"></textarea>
& ......
最近在sina看nba的文字直播的时候,对网站右下角的那一个聊天窗口产生兴趣,就决定自己也做一个。
上网查查资料,这样的聊天室无非就是用户输入数据传到服务器保存,然后用户页面再实时地从数据库取出数据,显示在页面上,即可完成一次聊天操作。
首先我定义了一个xml文件,用于保存用户的聊天数据,
<?xml version="1.0" encoding="utf-8"?>
<Messages>
<Message>
<users>crazyluo</users>
<data>ceshide</data>
<sendtime>23:25</sendtime>
<sendto>me</sendto>
</Message>
</Messages>
users保存发送信息的用户,data是发送的数据,sendtime是发送的时间,sendto是发送的对象
然后创建一个聊天的页面,页面代码大致是如下:
<div id="main">
<div id="msg"></div>
<div id="div1">
<textarea id="text" style="width:200px;"></textarea>
& ......
http://en.wikipedia.org/wiki/C_preprocessor
C preprocessor
from Wikipedia, the free encyclopedia
Jump to:navigation, search
The C preprocessor (cpp) is the preprocessor for the C programming language. In many C implementations, it is a separate program invoked by the compiler as the first part of translation. The preprocessor handles directives for source file inclusion (#include), macro definitions (#define), and conditional inclusion (#if). The language of preprocessor directives is agnostic to the grammar of C, so the C preprocessor can also be used independently to process other types of files.
The transformations it makes on its input form the first four of C's so-called Phases of Translation. Though an implementation may choose to perform some or all phases simultaneously, it must behave as if it performed them one-by-one in order.
Contents
[hide]
1 Phases
2 Including files
3 Conditional compilation
4 Macro definition and expansion
4.1 Standard predefined positio ......
#include<stdio.h>
#define N 8
void input(int n,int p[N][N])
{
int i,j;
for(i=0;i<n;i++)
{
printf("please input the %d line:\n",i+1);
for(j=0;j<n;j++)
{
scanf("%d",&p[i][j]);
}
}
}
void output(int n,int p[N][N])
{
int i,j;
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
{
printf("%d",p[i][j]);
}
}
}
void MATRIX_ADD(int n,int X[][N],int Y[][N],int Z[][N])
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
Z[i][j]=X[i][j]+Y[i][j];
}
void MATRIX_SUB(int n,int X[][N],int Y[][N],int Z[][N])
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
Z[i][j]=X[i][j]-Y[i][j];
}
void MATRIX_MULTIPLY(int A[][N],int B[][N],int C[][N])
{
int i,j,t;
for(i=0;i<2;i++)
for(j=0;j<2;j++)
{
C[i][j]=0;
for(t=0;t<2;t++)
C[i][j]=C[i][ ......
例) 危険なコーディング
1 char cStr[256];
2 ZeroMemory(cStr, sizeof(cStr));
3 strcpy(cStr, src); ← srcのサイズが256バイトを超えていた場合オーバーフロー!
修正)
1 char cStr[256];
2 ZeroMemory(cStr,0, sizeof(cStr));
3 strncpy(cStr, src, sizeof(cStr)-1);
危険な関数
代替関数
gets
fgets
strcat
strncat
strcpy
strncpy
sprintf
snprintf
vsprintf
vsnprintf
危険な例)
#in ......
C/C++ Reference
http://www.cppreference.com/
C++ Library Reference
http://www.cplusplus.com/ref/
Standard C++ Library Class Reference at Rogue Wave
http://www.roguewave.com/support/docs/hppdocs/stdref/
Dinkum C++ Library Reference Manual.
http://www.dinkumware.com/refxcpp.html
------------------------------------------------------------------
More About STL:
http://www.cs.rpi.edu/~musser/stl-book/ Effective STL
http://www.bdsoft.com/resources/estlcode.html Effective STL -Example S
ource Code
http://www.bdsoft.com/resources.html
http://www.bdsoft.com/tools/stlfilt.html STLFilt( free) An STL Error M
essage Decryptor for C++
http://www.oonumerics.org/blitz/download/ Bitz library
http://www.cs.auc.dk/%7E ......
C/C++ Reference
http://www.cppreference.com/
C++ Library Reference
http://www.cplusplus.com/ref/
Standard C++ Library Class Reference at Rogue Wave
http://www.roguewave.com/support/docs/hppdocs/stdref/
Dinkum C++ Library Reference Manual.
http://www.dinkumware.com/refxcpp.html
------------------------------------------------------------------
More About STL:
http://www.cs.rpi.edu/~musser/stl-book/ Effective STL
http://www.bdsoft.com/resources/estlcode.html Effective STL -Example S
ource Code
http://www.bdsoft.com/resources.html
http://www.bdsoft.com/tools/stlfilt.html STLFilt( free) An STL Error M
essage Decryptor for C++
http://www.oonumerics.org/blitz/download/ Bitz library
http://www.cs.auc.dk/%7E ......
《C专家编程》学习总结2
转自 : http://blog.chinaunix.net/u2/87570/showart_2120069.html
编译器做了些什么
图1:编译器通常分割成几个更小的程序
静态链接与动态链接
图2:静态链接与动态链接的区别
动态链接的优势:
1, 动态链接可执行文件比功能相同的静态链接的可执行文件的体积小。它能够节省磁盘空间和虚拟内存,因为函数库只有在需要时才被映射到进程中。以前,避免把函数库的拷贝绑定到每个可执行程序文件的惟一方法就是把服务器置于内核而不是函数库中,使得内核膨胀。
2, 所有动态链接到某个特定函数库的可执行文件在运行时共享该函数库的一个单独拷贝。操作系统内核保证映射到内存中的含数据库可以被使用它的其他进程共享,提供了更好的I/O和交换空间利用率,节省了物理内存,从而提高了系统的整体性能。如果可执行文件是静态链接的,每个文件都将拥有一份函数库的拷贝,显然极为浪费空间。
关于函数链接
1, 动态库文件的扩展名是.so,而静态库文件的扩展名是.a,并以libname的形 ......