Computer Science, asked by coolpieSid1303, 11 months ago

स्ट्रिंग कांस्टेंट (string constant) की परिभाषा बताइए।

Answers

Answered by HappyPrince14
0

Explanation:

String Constant

        A character string, a string constant consists of a sequence of characters enclosed in double quotes.

        A string constant may consist of any combination of digits, letters, escaped sequences and spaces.  Note that a character constant ۥAۥ

                  and the corresponding single character string constant "A" are not equivalent.

                 ۥAۥ        -           Character constant   -           ۥAۥ

                "A"       -           String Constant           -           ۥAۥ        and ۥ \0ۥ (NULL)

                The string constant "A" consists of character A and \0. However, a single character string constant does not have an equivalent integer value. It occupies two         

                bytes, one for the ASCII code of A and another for the NULL character with a value 0, which is used to terminate all strings. 

                Valid String Constants: -                "W"                 "100"              "24, Kaja Street"

                Invalid String Constants: -             "W              the closing double quotes missing

                                                                            Raja"         the beginning double quotes missing

Rules for Constructing String constants

1)        A string constant may consist of any combination of digits, letters, escaped sequences and spaces enclosed in double quotes.

2)        Every string constant ends up with a NULL character which is automatically assigned (before the closing double quotation mark) by the compiler.

Difference between single character constant and string constant

                                Character Constant                                                                                                                               String Constant

A character constant is enclosed within single inverted commas.                                         A sequence of characters enclosed in double quotes

The maximum length of a character constant can be one character.                                     A string constant can be any length.

A single character string constant has an equivalent integer value.                                       A single character string constant does not have an equivalent integer value.

The character constant ‘A’ consists of only character A.                                                           The string constant "A" consists of character A and \0.

A single character constant occupies one byte.                                                                          A single string constant occupies two bytes

Every character constant does not end up with a NULL character.                                         Every string constant ends up with a NULL character which is automatically 

                                                                                                                                                              assigned (before the closing double quotation mark) by the compiler

Answered by SanwiG
4

Explanation:

string constant in the future

Similar questions