Please enable JavaScript.
Coggle requires JavaScript to display documents.
String Manipulation (String Copy & Concatenate (Programs can be…
String Manipulation
-
-
Search
Many languages provide functions to search a string for a specific character or a set of characters within that string (substring), perhaps a word or even a few words.
-
result = SearchString(LongString, "best")
OR--MainString.find(findme, begin=0, end=len(MainString))-
Storage
Each character in a string is stored as a single byte. If there is more than one character in the string, the group is given a name and handled in the program as a single item
-
MyLargeString is handled as one variable. It takes 22 bytes of memory to store all of the characters in this string (remember that blank spaces take up as much space as any other character).
Assignment
This is done by putting the characters you want in the string in between a pair of speech marks, like this:
-
Traversal
String Length--i.e. the number of characters it contains. It can be useful to know the total number of characters, perhaps you might need to know the 4th and 6th character. Being able to identify the length of the string makes this possible.
String traversal--able to keep track of the position of every character within a string. This lets you locate or make changes to individual characters rather than changing the entire string.
Casting
String or character, integer, real or boolean
Maybe you want to play a game using lists of phone numbers that were entered as strings, but need the program to treat them as actual numbers. Converting from one data type to another is called casting.
A string variable stores text rather than a number. The string is made up of a set of characters that can also include spaces, symbols and numbers.e.g."a","this is a string","0145955"