Some errors... please help.
What I am trying to do is reading an array of characters from a file (only latin characters, and less than 100) and check whether there is any possible next permutation in lexicographical order or not. If there is, print it out in a file, else just print a message.
#include <fstream>
#include <vector>
usingnamespace std;
int main(int argc, char *argv[])
{
vector<char> array;
array.reserve(100);
int L;
ifstream in("code.in");
ofstream out("code.out");
while(in)
{
array.push_back(L);
}
if ( next_permutation(array) )
{
vector<char>::iterator character;
for(character = array.begin(); character != array.end; ++character)
{
out << *character << " ";
}
}
else
{
out << "This is the last code.";
}
in.close();
out.close();
return 0;
}
Errors:
Compiling source file(s)...
CI.cpp
CI.cpp: In function `int main(int, char**)':
CI.cpp:21: error: no matching function for call to `next_permutation(std::vector<char, std::allocator<char> >&)'
CI.cpp:25: error: no match for 'operator!=' in 'character != array.std::vector<_Tp, _Alloc>::end [with _Tp = char, _Alloc = std::allocator<char>]'
Sorry, couldn't access the forum for several hours after I tried to submit a reply. As Abstract noted, you are missing those ()'s. Also, it should be next_permutation(array.begin(),array.end());