# Functional Programming Strings - Functional Programming

## What are strings in Functional Programming?

A string is known as a group of characters including spaces. It is also called as a one-dimensional array of characters called as a NULL character (‘\0’). A string is also regarded as predefined class which is supported by most of the programming languages such as C, C++, Java, PHP, Erlang, Haskell, Lisp, etc.
Below mentioned image shows how the string "Tutorial" will look in the memory.

## Create a String in C++

Below mentioned program explains us how to create a string in C++, which is an object-oriented programming language.
It will produce the following output –

## String in Erlang

Below mentioned program is an example that explains us how to create a string in Erlang, which is a functional programming language.
It will produce the following output –

## String Operations in C++

Generally various programming languages support various methods on strings. Below mentioned table shows a few predefined string methods supported by C++.
S.No. Method & Description
1

Strcpy(s1,s2)

It copies the string s2 into string s1

2

Strcat(s1,s2)

It adds the string s2 at the end of s1

3

Strlen(s1)

It provides the length of the string s1

4

Strcmp(s1,s2)

It returns 0 when string s1 & s2 are same

5

Strchr(s1,ch)

It returns a pointer to the first occurrence of character ch in string s1

6

Strstr(s1,s2)

It returns a pointer to the first occurrence of string s2 in string s1

The following program shows how the above methods can be used in C++
It will produce the following output –

## String Operations in Erlang

Below mentioned table shows a list of predefined string methods supported by Erlang.
S.No. Method & Description
1

len(s1)

It provides the string s2 into string s1

2

equal(s1,s2)

It returns true when string s1 & s2 are equal else return false

3

concat(s1,s2)

It adds string s2 at the end of string s1

4

str(s1,ch)

It returns index position of character ch in string s1

5

str (s1,s2)

It returns index position of s2 in string s1

6

substr(s1,s2,num)

This method returns the string s2 from the string s1 based on the starting position & number of characters from the starting position

7

to_lower(s1)

This method returns string in lower case

Below mentioned program explains us how the above methods can be used in Erlang.
It will produce the following output –