ProAnswers.org

Write a C program to interchange the elements of a character array using pointer?

#include

#include 

void main() 

{ 

char *names[]={“anand”,“murugan”,“selvaraj”, “annammal”,”shrikarthick”, “renukadevi”}; 

char*tmp; 

clrscr(); 

printf(“original: %s%s”, names[3], names[4]); 

tmp=names[3]; 

names[3]=names[4]; 

names[4]=temp; 

printf(“

New : %s%s”,names[3],names[4]);

getch(); 

} 

Output: 

Original : annammal shrikarthick 

New :shrikarthick annammal