2. String is an array of characters.
char name[]={‘R', ‘A', ‘V', ‘I', ‘N', '0’};
NULL character (0) will automatically be inserted at the end of the
string.
'0' represents the end of the string. It is also referred as String
terminator & Null Character.
3. String Functions
• Strlen – Find out length of the string
• Strcat – Concatenates of two string
• Strcmp – Comparing of two string
• Strcpy – Copies the string
5. • Pointer is a variable that contain the address of other variable.
• A Pointer in C is used to allocate memory dynamically i.e. at run
time. The pointer variable might be belonging to any of the data type
such as int, float, char, double, short etc.
• Pointer Syntax : data_type *var_name; Example : int *p; char *p;
• Where, * is used to denote that “p” is pointer variable and not a
normal variable.
6. KEY POINTS TO REMEMBER ABOUT POINTERS IN C:
• Normal variable stores the value whereas pointer variable stores the
address of the variable.
• The content of the C pointer always be a whole number i.e. address.
• Always C pointer is initialized to null, i.e. int *p = null.
• The value of null pointer is 0.
• & symbol is used to get the address of the variable.
• * symbol is used to get the value of the variable that the pointer is
pointing to.
• If a pointer in C is assigned to NULL, it means it is pointing to nothing.
8. /*C program to create, initialize, assign and access a pointer variable.*/
#include <stdio.h>
int main()
{
int num; /*declaration of integer variable*/
int *pNum; /*declaration of integer pointer*/
pNum=& num; /*assigning address of num*/
num=100; /*assigning 100 to variable num*/
//access value and address using variable num
printf("Using variable num:n");
printf("value of num: %dnaddress of num: %un",num,&num);
//access value and address using pointer variable num
printf("Using pointer variable:n");
printf("value of num: %dnaddress of num: %un",*pNum,pNum);
return 0;
}