level 2
LostAFound
楼主
#include<iostream>
#include<fstream>
#include <string>
#include <vector>
#include<cstdlib>
#include<ctime>
#pragma hdrstop
using namespace std;
int main()
{
std::vector<std::string> word;
std::string line;
word.clear();
std::ifstream infile ("dictionary.txt", std::ios_base::in);
while (getline(infile, line, '\n'))
{
word.push_back (line);
}
std::vector<std::string> word;
srand((unsigned)time(NULL));
int s;
s=rand()%word.size();
std::cout << "Read " << word.size() << " lines.\n";
//word[s];
string words = "word[s]";
char letter = words[0];
cout << letter << endl;
cout << "Please a world~";
vector<char> ;
cin >> ;
===================================================================
H:\Bill Zhang E\Final Project\FP.cpp||In function 'int main()':|
H:\Bill Zhang E\Final Project\FP.cpp|21|error: redeclaration of '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> > > > word'|
H:\Bill Zhang E\Final Project\FP.cpp|13|error: '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> > > > word' previously declared here|
H:\Bill Zhang E\Final Project\FP.cpp|31|error: declaration does not declare anything|
H:\Bill Zhang E\Final Project\FP.cpp|32|error: expected primary-expression before 'char'|
H:\Bill Zhang E\Final Project\FP.cpp|32|error: expected ';' before 'char'|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 0 seconds) ===|
2014年05月30日 00点05分
1
#include<fstream>
#include <string>
#include <vector>
#include<cstdlib>
#include<ctime>
#pragma hdrstop
using namespace std;
int main()
{
std::vector<std::string> word;
std::string line;
word.clear();
std::ifstream infile ("dictionary.txt", std::ios_base::in);
while (getline(infile, line, '\n'))
{
word.push_back (line);
}
std::vector<std::string> word;
srand((unsigned)time(NULL));
int s;
s=rand()%word.size();
std::cout << "Read " << word.size() << " lines.\n";
//word[s];
string words = "word[s]";
char letter = words[0];
cout << letter << endl;
cout << "Please a world~";
vector<char> ;
cin >> ;
===================================================================
H:\Bill Zhang E\Final Project\FP.cpp||In function 'int main()':|
H:\Bill Zhang E\Final Project\FP.cpp|21|error: redeclaration of '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> > > > word'|
H:\Bill Zhang E\Final Project\FP.cpp|13|error: '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> > > > word' previously declared here|
H:\Bill Zhang E\Final Project\FP.cpp|31|error: declaration does not declare anything|
H:\Bill Zhang E\Final Project\FP.cpp|32|error: expected primary-expression before 'char'|
H:\Bill Zhang E\Final Project\FP.cpp|32|error: expected ';' before 'char'|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 0 seconds) ===|