Current location - Health Preservation Learning Network - Fitness coach - Ali fitness
Ali fitness
int strcpy(char *s 1,const char * S2);

Open the buffer, such as

char buff[ 100]; //Suppose you don't have more than this many strings.

Yours is an array

char * * argv

Where argv[0] = "This is the first string";

Argv[ 1] = "This is the second string";

You just need to call the following

strcpy(buff,argv[0]);

strcpy(argv[0],argv[ 1]);

strcpy(argv[ 1],buff);

Here is the complete code, and has been tested.

# include & ltstdio.h & gt

# include & ltstring.h & gt

Char argv[2][ 100]={ "This is the first string" and "This is the second string"};

//Stores a two-dimensional array of strings, and the maximum length of each string is 99 bytes.

char buff[ 100];

//buffer

int main()

{

Printf ("Before conversion: \ n");

printf("argv[0] = %s\n ",argv[0]);

printf("argv[ 1] = %s\n ",argv[ 1]);

strcpy(buff,argv[0]);

strcpy(argv[0],argv[ 1]);

strcpy(argv[ 1],buff);

Printf ("after conversion: \ n");

printf("argv[0] = %s\n ",argv[0]);

printf("argv[ 1] = %s\n ",argv[ 1]);

Returns 0;

}