TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Thursday, 14 May 2020

String In C Language | String In C Language In Hindi

String In C Language

In C programming a string is a sequence of characters terminated with null character \0.

Example:

char   c[]=”c  string”;

the compiler encounter a sequence of character enclosed in the double quotation marks, it oppends a null character \0 at the ends by  default.

string image in c

String in c


How to declare string?

Here we will declare string:

char       s[5];

image of declaration in string in c

Declare string


How to initialize strings?

We can initialize string in a number of ways.

char   c[]=”abc”;

char   c[50]=”abcd”;

char   c[]= {‘a’,’ b’, ’c’, ’d’, ‘\0’);

char   c[5]= {‘a’,’ b’, ’c’, ’d’, ‘\0’);


image of initialize of string in c

Initialize string


Assigning Value to  strings

Array and string are second-class citizen in c. they do not support assignment operator once it is delcareed.


Example:


char   c[10];

c= “C programming”;


Program:


#include<stdio.h>

#include<conio.h>

void main()

{

char name[20];

printf(“Enter name :”);

scanf(“%s”,name);

printf(“your name is %s”, name);

getch();

}


Output:


Enter your name:

pramod

Your name is : pramod


No comments:

Post a Comment