Download presentation
Presentation is loading. Please wait.
1
Character Arrays char string1[] = “first”;
Note : string1 contains 5 characters plus a string termination character or null character – ‘\0’. char string1[] = { ‘f ‘ , ‘i ‘, ‘r ‘ , ‘s ‘ , ‘t ‘ , ‘ \0 ‘}; A String is an array of characters. A character array representing a string can be displayed with %s. printf(“%s \n”, string1); gets(string1); fflush(stdin);
2
#include < stdio.h>
int main() { char string1[20], string2[] = “abcd”; int i; printf(“Enter a string \n”); scanf(“%s”, string1); printf(“ String1 is : %s \n”, string1); printf(“ String2 is : %s \n”, string2); for( i = 0; string1[ i ] != ‘\0’ ; i++) printf(“ %c ”, string1[i]); printf(“\n”); return 0; }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.