W
wukexin
I try some kind of compiler, my program compile succeeding, but run wrongly.
Help me, see my program. If you have free time, please give me some
suggestion about process command argument. Thank you very much.
//
#include <iostream>
#include <fstream>
#include <list>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
const bool display_command(vector<string>& s);
bool argument_process(int argc,char* argv[],vector<string>::iterator ptr);
bool display_help();
int main(int argc,char* argv[])
{
static vector<string> message;
vector<string>::iterator ptr=message.begin();
if(argc<1)
{
cerr<<"The program get a abnormal mistake!"<<endl;
}
argument_process(argc,argv,ptr);
return 0;
}
/////////////////////
void print(string s)
{
cout<<s;
}
/////////////////////
const bool display_command(vector<string>& s)
{
for_each(s.begin(),s.end(),print);
return true;
}
////////////////
bool argument_process(int argc,char* argv[],vector<string>::iterator ptr)
{
vector<string> command;
if(1==argc)
{
display_help();
}
for(int i=1;i<argc;i++)
{
command.push_back(argv);
sort(command.begin()+1,command.end());
copy(command.begin()+1,command.end(),ptr);
}
display_command(command);
return true;
}
//
bool display_help()
{
cout<<"display help"<<endl;
return true;
}
Help me, see my program. If you have free time, please give me some
suggestion about process command argument. Thank you very much.
//
#include <iostream>
#include <fstream>
#include <list>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
const bool display_command(vector<string>& s);
bool argument_process(int argc,char* argv[],vector<string>::iterator ptr);
bool display_help();
int main(int argc,char* argv[])
{
static vector<string> message;
vector<string>::iterator ptr=message.begin();
if(argc<1)
{
cerr<<"The program get a abnormal mistake!"<<endl;
}
argument_process(argc,argv,ptr);
return 0;
}
/////////////////////
void print(string s)
{
cout<<s;
}
/////////////////////
const bool display_command(vector<string>& s)
{
for_each(s.begin(),s.end(),print);
return true;
}
////////////////
bool argument_process(int argc,char* argv[],vector<string>::iterator ptr)
{
vector<string> command;
if(1==argc)
{
display_help();
}
for(int i=1;i<argc;i++)
{
command.push_back(argv);
sort(command.begin()+1,command.end());
copy(command.begin()+1,command.end(),ptr);
}
display_command(command);
return true;
}
//
bool display_help()
{
cout<<"display help"<<endl;
return true;
}