A simple program to understand how to work with strings.
#include <stdio.h> #include <stdlib.h> int main(void) { char name[10] = {'H','E','L','L','O'} ; char name2[10] = {'G','O','O','D','B','Y','E'} ; char temp[10] ; int i; printf("Name 1 is %s\n",name); printf("Name 2 is %s\n",name2); printf("\n"); for(i=0; i<10; i++) { temp[i]= name[i]; name[i] = name2[i]; name2[i] = temp[i]; } printf("After The string copy function\n"); printf("\n"); printf("Name 1 is %s\n",name); printf("Name 2 is %s\n",name2); system("PAUSE"); return 0; }
Feed for this Entry Trackback Address The permalink
Be the first to comment this entry.


Recent Comments