Wednesday 7 April 2021

Character String Types | PPL | Sebesta | Elementary Data Types in Programming Language

                   In this post, we will see Character String Types | PPL | Sebesta | Elementary Data Types in Programming Language | character string types, data types in ppl, data types ppl, elementary data types in programming language, ppl, sebesta, introduction  


3. Character String types

 

              A character string type is one in which the values consist of sequences of characters.

 

Strings and Their Operations

              The most common string operations are assignment, concatenation, substring reference, comparison, and pattern matching.

              Character string types could be supported directly in hardware; but in most cases, software is used to implement string storage, retrieval, and manipulation.

 

Implementation

 

i. C and C++

              C and C++ use char arrays to store character strings.

 

e.g.

char mystring[]="Parag";

OR

char mystring[5]={'p','a','r','a','g'};

 

ii. Java

 

              In Java, strings are supported by the String class, whose values are constant strings, and the StringBuffer class, whose values are changeable and are more like arrays of single characters.

 

e.g.

String s="Parag";

String s1=new String("Parag");

StringBuffer s2=new StringBuffer("Parag");

 

iii. C# and Ruby

              C# and Ruby include string classes that are similar

to those of Java.

 

iv. Python

              Python includes strings as a primitive type i.e. str.

              For character and substring references, they act very much like arrays of characters.

              However, Python strings are immutable, similar to the String class objects of Java.

 

v. F#

              In F#, strings are a class.

 

vi. ML

              In ML, string is a primitive immutable type.

 

 

              Perl, JavaScript, Ruby, and PHP include built-in pattern-matching operations. They use Regular Expressions for pattern matching.

              Pattern-matching capabilities using regular expressions are included in the class libraries of C++, Java, Python, C#, and F#.

 

String Length Options

              The length can be static and set when the string is created. Such a string is called a static length string. e.g. Java, Python.

              Limited dynamic length strings are those strings which are allowed to have varying length up to a

declared and fixed maximum set by the variable’s definition. e.g. C, C++.

              Dynamic length strings are those strings which have varying length with no maximum. e.g. JavaScript, Perl, and the standard C++ library.

 

              Ada 95+ supports all three string length options.

 

Descriptor for Static Length Strings




Descriptor for Limited Dynamic Length Strings


 

 

              Dynamic length strings require a simpler run-time descriptor because only the current length needs to be stored.


Watch following video:

Watch on YouTube: https://www.youtube.com/watch?v=q-jAz8AMOFo


No comments:

Post a Comment