Important Notice:

Course Content
Building IoT Applications (Chapter-4) M4-R5.1
About Lesson

STRINGS:

  • A string is a collection of characters.

  • A string is also called as an array of characters. 63

  • A String must access by %s access specifier in c and c++.

  • A string is always terminated with (Null) character.

  • Example of string: ―Akhilesh‖

  • A string always recognized in double quotes.

  • A string also consider space as a character.

  • Example: ‖ Akhilesh Sir‖

  • The above string contains 12 characters.

  • Example: Char ar[20]

  • The above example will store 19 character with I null character.

 

Syntax: char string_name[size];

 

Example:-

        WAP to accept a complete string (first name and last name) and display hello message in the output.

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char st1[25];
char st2[25];
printf(“Enter first Name”);
scanf(“%s”,&st1);
printf(“Enter Second Name”);
scanf(“%s”,&st2);
puts(st1);
puts(st2);
getch();
}

 

error: Content is protected !!