这个程序在VC6.0下运行通过,但DEV C++下有3个错,请教/
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
题目:
Create a program that opens a file and counts the whitespace-separated words in that file.
//1.3.cpp
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
void main() {
vector<string> words;
ifstream in("1.3.cpp");
string word;
while(in>>word)
words.push_back(word);
for( int i=0; i<words.size(); i++)
{//if (words[i]==" ") ++m;
}
cout<<i-1 <<endl; //我直接用总词汇减去1,觉地既是要求的答案
}
这个程序在VC6.0下运行通过,但DEV C++下有3个错
问题点数:5、回复次数:2Top
1 楼CAT323(CAT323)回复于 2003-12-04 01:09:54 得分 5
晕死
我用VC++6.0编译 出了12个错误
不看了
第一个臭风格就是void main()
Top
2 楼boyplayee()回复于 2003-12-04 08:37:54 得分 0
NO。我用的VC++6.0结果是34,
D:\C++\1.3.cpp(19) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char
>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,int>' : identifier was truncated to '255' characters in the debug information
D:\C++\1.3.cpp(19) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std:
:allocator<char> > &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,int>' : identifier was truncated to '255' characters in the debug information
e:\编程工具\vc98\include\vector(39) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::vector<std::basic_string<
char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
e:\编程工具\vc98\include\vector(60) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::~vector<std::basic_string
<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
Linking...
1.3.exe - 0 error(s), 5 warning(s)
Top




