This code function has a password verification function (here there is no echo operation, that is, use * to replace the input content ), after the verification is passed, the output content is determined by the number of executed parameters. If the parameter is the program itself, the command content in the output text will match the text content if the parameter is included, if the match is successful, run the command. If the match is unsuccessful, the command is not found. Code directly: [cpp]/** ======================================== ========================================================== =============** Filename: main. cpp ** Description: ** Version: 1.0 * Created: 03/12/2013 05:44:05 PM * Revision: none * Compiler: gcc ** Author: BackGarden_Straw.Neo (BackGarden_Straw), 20549304@163.com * Organization: backGarden_Straw ** =========================================== ====================================== =================================* // Define the header file # include <stdio. h> # include <stdlib. h> # include <string. h> # include <sys/types. h> // define the marco var # define SIZE 1024 int main (int argc, const char * argv []) {// input the test login in executable program. char Password [] = {"test"}; char LoginPassword [16]; do {printf ("please input password to login:"); scanf ("% s ", loginPassword); // printf ("1 = % d, 2 = % d, 3 = % d \ n ", strcmp (Password, LoginPassword), strlen (Password), strlen (LoginPassword )); // printf ("1 = % d, 2 = % d, 3 = % d \ n", strcmp (Password, LoginPassword), strlen (Password ), strlen (LoginPassword); if (strcmp (Password, LoginPassword) = 0) & (strlen (Password) = strlen (LoginPassword ))) {printf ("Enjoy it! \ N "); break;} else {printf (" your password can't login. \ n "); exit (0) ;}} while (1); // do what after login FILE * source; const char CommandPath [] = {" command.txt "}; char Buffer [SIZE]; int status = 0; if (! (Source = fopen (CommandPath, "r") {printf ("command file can't read or not exist. \ n "); exit (1);} // List the commands or execute the command if (argc <2) {// List the commands printf (" Command List: \ n "); while (fgets (Buffer, sizeof (Buffer), source) {printf (" % s ", Buffer );}} else {// Check the command while (fgets (Buffer, sizeof (Buffer), source) {if (strncmp (argv [1], Buffer, strlen (Buffer)-1) = 0) {printf ("Find the command. \ n "); status = 1; // send the command to services char ReceiveCommand [SIZE]; int I = 0; for (I = 1; I <argc; I ++) {strcat (ReceiveCommand, argv [I]); strcat (ReceiveCommand, "");} printf ("the command is: % s \ n", ReceiveCommand ); break;} else {continue;} if (status = 0) {printf ("sorry, can't find your command \ n ");}} // close the command file if (fclose (source) {printf ("Error in cl Ose file "); exit (1);} return 0;} The amount of code is small, so there will be no more comments. Ps: at execution time, a command.txt file is stored in the same level directory.