Working With Strings: Char Greeting (6) ('H', 'E', 'L', 'L', 'O', '/0')
Working With Strings: Char Greeting (6) ('H', 'E', 'L', 'L', 'O', '/0')
Working With Strings: Char Greeting (6) ('H', 'E', 'L', 'L', 'O', '/0')
If you follow the rule of array initialization then you can write the above
statement as follows −
char greeting[] = "Hello";
Live Demo
#include <stdio.h>
int main () {
return 0;
When the above code is compiled and executed, it produces the following
result −
Greeting message: Hello
1 strcpy(s1, s2);
2 strcat(s1, s2);
3 strlen(s1);
4 strcmp(s1, s2);
6 strstr(s1, s2);
#include <stdio.h>
#include <string.h>
int main ()
char str3[12];
int len ;
strcpy(str3, str1);
len = strlen(str1);
When the above code is compiled and executed, it produces the following
result.
strcpy( str3, str1) : Hello
strcat( str1, str2): HelloWorld
strlen(str1) : 10