C examples for String:char array
Swap Strings Physically, swap the strings in a 2-dimensional array of characters
#include <stdio.h> int main()//from w w w.ja v a 2 s . co m { char temp; char friends [5][10] = { "abc", "def test", "1234", "12345", "99" }; printf("Strings before swapping:\n"); for(int i = 0; i < 5; i++) printf("Friend no. %d : %s\n", i+1, friends[i]); for(int i = 0; i < 10; i++) { temp = friends[0][i]; friends[0][i] = friends[1][i]; friends[1][i] = temp; } printf("\nStrings after swapping:\n"); for(int i = 0; i < 5; i++) printf("Friend no. %d : %s\n", i+1, friends[i]); return(0); }