C examples for String:char array
Swap Strings Logically, swaps the strings using an array of pointers to strings
#include <stdio.h> int main(){/*from w w w . j a v a2s . c o m*/ char *temporary; char *friends [5] = { "1111111", "11111", "11", "111", "1111" }; printf("Strings before swapping:\n"); for(int i = 0; i < 5; i++) printf("Friend no. %d : %s\n", i+1, friends[i]); temporary = friends[1]; friends[1] = friends[0]; friends[0] = temporary; printf("\nStrings after swapping:\n"); for(int i = 0; i < 5; i++) printf("Friend no. %d : %s\n", i+1, friends[i]); return(0); }