一个空格引起的“惨案”

         经历1:

         某次, 在某大型工程中, 我多敲了一个空格, 于是, 在编译的时候一直报错。 下面给出一个例子:

 

[taoge@localhost Desktop]$ cat main.c 
#include < stdio.h>

int main()
{
	return 0;
}
[taoge@localhost Desktop]$ gcc main.c 
main.c:1:20: error:  stdio.h: No such file or directory
[taoge@localhost Desktop]$

 

         编译的时候, 找不到头文件, 但我看到头文件明明在对应的目录下啊, 经过一段时间的仔细确认, 终于发下了程序的错误, 原来多了一个空格, 如上。

 

 

         经历2:

         某次, 两个终端登录同一服务器的同一目录, 执行相同的操作, 结果得到不同的结果。

         经过一段时间的跟踪确认, 终于发现, 这么目录下有两个几乎完全一致的文件, 如下:

 

[taoge@localhost test]$ ls
[taoge@localhost test]$ touch "a.txt" " a.txt"
[taoge@localhost test]$ ls
 a.txt  a.txt
[taoge@localhost test]$ ll
total 0
-rw-rw-r-- 1 taoge taoge 0 Oct 27 08:45  a.txt
-rw-rw-r-- 1 taoge taoge 0 Oct 27 08:45 a.txt
[taoge@localhost test]$ 

 

 

 

 

 

        经历3: 

        不是我的经历, 某程序员写下了如下代码并编译, 如下:

 

[taoge@localhost test]$ cat test.cpp 
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main()
{
	vector<map<int, int>> v;
	return 0;
}
[taoge@localhost test]$ g++ test.cpp 
test.cpp: In function ‘int main()’:
test.cpp:8: error: ‘>>’ should be ‘> >’ within a nested template argument list
[taoge@localhost test]$ 

       该怎么修改, 我就不说了, 上面的提示已经说得很清楚了。 当然, 在C++ 11中, 上述程序是OK的, 但不要依赖于这种靠兼容吃饭的行为。

 

 

  

       空格虽小, 不可忽视。 睡觉。

 

 

 

 


 

 

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值