Array and String

We can consider String as an character array and it can be declared and initialized as follows:

char str[5] = "hello";

C supports an alternative to create a String using Pointer as follows:

char *str = "hello";
or
char *str;
str = "hello";

In above declaration str is a character pointer which stores the memory address of first letter of string hello.

We can also point character pointer to character array if we want to take array content at run time from user.

char str[50], *p;
p = &str[0];    or     p=str;

The below program will join or append two strings using pointer and without using string library functions.

Program Code:
Copy to Clipboard
Output:
Enter String 1: Hello
Enter String 2: How are you
Joined String = HelloHow are you

Thanks for Visit..!