长沙 Day 1

原定于 4 月 29 日晚 23 时 50 分发车的 K6624 次列车,在广州站发生大面积晚点的背景下,晚点 3 小时又 10 分钟,终于在 30 号的凌晨三点钟拉响了出发的汽笛。经过 8 个小时的不眠煎熬,我们终于在十一时许到达了长沙火车站。

【珍爱生命,远离绿车】

继续阅读长沙 Day 1

在 Xcode 控制台中输入 EOF

在终端(Terminal)中,我们可以使用组合键 control + D 来输入一个 EOF,但是此法在 Xcode 控制台中行不通。有两个在控制台输入 EOF 的方法。

  1. 按照顺序按下组合键 control + Q, control + D。
  2. 按下组合键 option + shift + /,此时控制台中会出现字符“¿”,回车即可。

The Overloading of Operator << and >>

class String {
public:
    friend ostream& operator<<(ostream&, const String&);
    friend istream& operator>>(istream&, String&);
    //other members
private:
    char *str;
};

ostream& operator<<(ostream& os, const String& str){
    int i=0;
    while (*(str.str+i)!='
class String {
public:
friend ostream& operator<<(ostream&, const String&);
friend istream& operator>>(istream&, String&);
//other members
private:
char *str;
};
ostream& operator<<(ostream& os, const String& str){
int i=0;
while (*(str.str+i)!='\0') os<<*(str.str + i++);
return os;
}
istream& operator>>(istream& is, String& str){
is>>str.str;
return is;
}
') os<<*(str.str + i++); return os; } istream& operator>>(istream& is, String& str){ is>>str.str; return is; }

MySQL [2002]: No such file or directory

在 OS X 系统下使用 MySQL 可能会遇到错误:

Warning: mysql_connect(): [2002] No such file or directory

解决方法不难:

检查 /tmp 和 /var/mysql 下是否有 mysql.sock 这个文件。

若前者有此文件而后者没有,执行以下命令:

cd /var 
sudo mkdir mysql
sudo chmod 755 mysql
cd mysql
sudo ln -s /tmp/mysql.sock mysql.sock

若后者有此文件而前者没有,执行以下命令:

cd /tmp
ln -s /var/mysql/mysql.sock mysql.sock

问题一般能够解决。

参考