Twelve String
![]() |
Strings in C-programming
A string is a sequence of characters. Any sequence or set of characters defined within double quotation symbols is a constant string. In c it is required to do some meaningful operations on strings they are:
- Reading string displaying strings
- Combining or concatenating strings
- Copying one string to another.
- Comparing string & checking whether they are equal
- Extraction of a portion of a string
Strings are stored in memory as ASCII codes of characters that make up the string appended with ‘’(ASCII value of null). Normally each character is stored in one byte, successive characters are stored in successive bytes.
Initializing Strings
Following the discussion on characters arrays, the initialization of a string must the following form which is simpler to one dimension array.
char month1[ ]={‘j’,’a’,’n’,’u’,’a’,’r’,’y’};
Then the string month is initializing to January. This is perfectly valid but C offers a special way to initialize strings. The above string can be initialized char month1[]=”January”; The characters of the string are enclosed within a part of double quotes. The compiler takes care of string enclosed within a pair of a double quotes. The compiler takes care of storing the ASCII codes of characters of the string in the memory and also stores the null terminator in the end.
/*String.c string variable*/
#include < stdio.h >
main()
{
char month[15];
printf (“Enter the string”);
gets (month);
printf (“The string entered is %s”, month);
}
In this example string is stored in the character variable month the string is displayed in the statement.
printf(“The string entered is %s”, month”);
It is one dimension array. Each character occupies a byte. A null character () that has the ASCII value 0 terminates the string. The figure shows the storage of string January in the memory recall that specifies a single character whose ASCII value is zero.
J
A
N
U
A
R
Y
Character string terminated by a null character ‘’.
A string variable is any valid C variable name & is always declared as an array. The general form of declaration of a string variable is
Char string_name[size];
The size determines the number of characters in the string name.
Example:
char month[10];
char address[100];
The size of the array should be one byte more than the actual space occupied by the string since the complier appends a null character at the end of the string.
Reading Strings from the terminal:
The function scanf with %s format specification is needed to read the character string from the terminal.
Example:
char address[15];
scanf(“%s”,address);
Scanf statement has a draw back it just terminates the statement as soon as it finds a blank space, suppose if we type the string new york then only the string new will be read and since there is a blank space after word “new” it will terminate the string.
Note that we can use the scanf without the ampersand symbol before the variable name.
In many applications it is required to process text by reading an entire line of text from the terminal.
The function getchar can be used repeatedly to read a sequence of successive single characters and store it in the array.
We cannot manipulate strings since C does not provide any operators for string. For instance we cannot assign one string to another directly.
For example:
String=”xyz”;
String1=string2;
Are not valid. To copy the chars in one string to another string we may do so on a character to character basis.
Writing strings to screen:
The printf statement along with format specifier %s to print strings on to the screen. The format %s can be used to display an array of characters that is terminated by the null character for example printf(“%s”,name); can be used to display the entire contents of the array name.
Arithmetic operations on characters:
We can also manipulate the characters as we manipulate numbers in c language. When ever the system encounters the character data it is automatically converted into a integer value by the system. We can represent a character as a interface by using the following method.
X=’a’;
Printf(“%dn”,x);
Will display 97 on the screen. Arithmetic operations can also be performed on characters for example x=’z’-1; is a valid statement. The ASCII value of ‘z’ is 122 the statement the therefore will assign 121 to variable x.
It is also possible to use character constants in relational expressions for example
ch>’a’ && ch < = ’z’ will check whether the character stored in variable ch is a lower case letter. A character digit can also be converted into its equivalent integer value suppose un the expression a=character-‘1’; where a is defined as an integer variable & character contains value 8 then a= ASCII value of 8 ASCII value ‘1’=56-49=7.
We can also get the support of the c library function to converts a string of digits into their equivalent integer values the general format of the function in x=atoi(string) here x is an integer variable & string is a character array containing string of digits.
String operations (string.h)
C language recognizes that string is a different class of array by letting us input and output the array as a unit and are terminated by null character. C library supports a large number of string handling functions that can be used to array out many o f the string manipulations such as:
- Length (number of characters in the string).
- Concatentation (adding two are more strings)
- Comparing two strings.
- Substring (Extract substring from a given string)
- Copy(copies one string over another)
To do all the operations described here it is essential to include string.h library header file in the program.
strlen() function:
This function counts and returns the number of characters in a string. The length does not include a null character.
Syntax n=strlen(string);
Where n is integer variable. Which receives the value of length of the string.
Example
length=strlen(“Hollywood”);
The function will assign number of characters 9 in the string to a integer variable length.
/*writr a c program to find the length of the string using strlen() function*/
#include < stdio.h >
include < string.h >
void main()
{
char name[100];
int length;
printf(“Enter the string”);
gets(name);
length=strlen(name);
printf(“nNumber of characters in the string is=%d”,length);
}
strcat() function:
when you combine two strings, you add the characters of one string to the end of other string. This process is called concatenation. The strcat() function joins 2 strings together. It takes the following form
strcat(string1,string2)
string1 & string2 are character arrays. When the function strcat is executed string2 is appended to string1. the string at string2 remains unchanged.
Example
strcpy(string1,”sri”);
strcpy(string2,”Bhagavan”);
Printf(“%s”,strcat(string1,string2);
From the above program segment the value of string1 becomes sribhagavan. The string at str2 remains unchanged as bhagawan.
strcmp function:
In c you cannot directly compare the value of 2 strings in a condition like if(string1==string2)
Most libraries however contain the strcmp() function, which returns a zero if 2 strings are equal, or a non zero number if the strings are not the same. The syntax of strcmp() is given below:
Strcmp(string1,string2)
String1 & string2 may be string variables or string constants. String1, & string2 may be string variables or string constants some computers return a negative if the string1 is alphabetically less than the second and a positive number if the string is greater than the second.
Example:
strcmp(“Newyork”,”Newyork”) will return zero because 2 strings are equal.
strcmp(“their”,”there”) will return a 9 which is the numeric difference between ASCII ‘i’ and ASCII ’r’.
strcmp(“The”, “the”) will return 32 which is the numeric difference between ASCII “T” & ASCII “t”.
strcmpi() function
This function is same as strcmp() which compares 2 strings but not case sensitive.
Example
strcmpi(“THE”,”the”); will return 0.
strcpy() function:
C does not allow you to assign the characters to a string directly as in the statement name=”Robert”;
Instead use the strcpy(0 function found in most compilers the syntax of the function is illustrated below.
strcpy(string1,string2);
Strcpy function assigns the contents of string2 to string1. string2 may be a character array variable or a string constant.
strcpy(Name,”Robert”);
In the above example Robert is assigned to the string called name.
strlwr () function:
This function converts all characters in a string from uppercase to lowercase.
syntax
strlwr(string);
For example:
strlwr(“EXFORSYS”) converts to exforsys.
About the Author
Rajat Bhutani
Pursuing B-Tech(electronics and communication)-3rd yr
from The Technological Institute of Textile and Sciences,Bhiwani
|
|
Backbeat Books Rickenbackers And Twelve String Electrics $22.49 Backbeat Books Rickenbackers And Twelve String Electrics |
|
|
Twelve String Symphonies (Pople, London Festival Orchestra) $14.49 Twelve String Symphonies (Pople, London Festival Orchestra) |
|
|
Used Takamine Eg345c Twelve String A/E $399.99 In Store Used USED TAKAMINE EG345C TWELVE STRING A/E |
|
|
Anthology Of The Twelve String Guitar $13.99 Track Listing: 1. Bull Durham - Glen Campbell, 2. Nashville - Mason Williams, 3. 12 String Guitar Rag - Bob Gibson, 4. Saints Soul Song - Roger McGuinn, 5. Color Him Folky - Howard Roberts, 6. My Little Maggie - Joe Maphis, 7. Blues Wail - Billy Strange, 8. Honey Miss Me When I'm Gone - Mason Williams, 9. Cottonfields - Howard Roberts, 10. Six by Twelve - Joe Maphis |
|
|
The Complete Twelve String Story $14.99 Track Listing: 1. Finger Buster Blues - Dick Rosmini, 2. Meadowlands - Fred Gerlach, 3. Hoot Blues - Mason Williams, 4. Guitar Rag - Bob Gibson, 5. Guitar Ramblin' - Tommy Tedesco, 6. When the Saints Go Marching In - Roger McGuinn, 7. Color Him Folky - Howard Roberts, 8. Maggie - Joe Maphis, 9. Good Old Blues - Frank Hamilton, 10. Redwing - Glen Campbell, 11. Blues Wail - Billy Strange, 12. Careless Love - Jim Helms, 13. Closer Walk, A - Dick Rosmini, 14. Take This Hammer - Tommy Tedesco, 15. Alabama Bound - Frank Hamilton, 16. Six by Twelve - Joe Maphis, 17. Honey Miss Me When I'm Gone - Mason Williams, 18. Midnight Train - Jim Helms, 19. Cottonfields - Howard Roberts, 20. Ramblin' On - Roger McGuinn, 21. Bull Durham - Glen Campbell, 22. Wildwood Flower - Billy Strange, 23. Twelfth Night - Fred Gerlach, 24. Loco Twelve String - Jim Helms |
|
|
Vintage Yamaha 1970S Fg260 Twelve String Acoustic $199.99 In Store Vintage VINTAGE YAMAHA 1970S FG260 TWELVE STRING ACOUSTIC 061911 621 |
|
|
Used Greg Bennett D-2-12 Twelve String Acoust Gtr $179.99 In Store Used USED GREG BENNETT D-2-12 TWELVE STRING ACOUST GTR |
|
|
Atlanta Twelve String $11.99 Track Listing: 1. Kill It Kid, 2. Razor Ball, The, 3. Little Delia, 4. Broke Down Engine Blues, 5. Dying Crapshooter's Blues, 6. Pinetop's Boogie Woogie, 7. Blues Around Midnight, 8. Last Dime Blues, 9. On the Cooling Board, 10. Motherless Children Have a Hard Time, 11. I Got to Cross the River Jordan, 12. You Got to Die, 13. Ain't It Grand to Live a Christian, 14. Pearly Gates, 15. Soon This Morning |
|
|
Twelve $6.49 Twelve |
|
|
Twelve Duets $9.95 By Leopold Mozart (1719-1787). For Violin. Duet or Duo; Masterworks; String - 2 Violins. Kalmus Edition. Baroque; Classical; Masterwork. Book. 16 pages. Published by Alfred Music Publishing |
|
|
The String $13.99 The String |
|
|
Sound Of Twelve String Guitar & Banjo (Rmst) $14.99 Essential Media Afw:942312355 |
|
|
Folkniks - Sound of Twelve String Guitar & Banjo $26.72 Disc 0:No track list available |
|
|
Twelve Preludes and Fugues $14.99 Full performer name: Colorado String Quartet/Colorado Saxophone Quartet/Michael Pagan. |
|
|
Alvarez Artist Series Ad60-12 Dreadnought Twelve String Acoustic Guitar Natural $339 The Alvarez Artist Series AD60-12 Dreadnought Twelve String Acoustic Guitar model is the 12-string version of the best-selling AD60 and sounds incredible. The AD60-12 is a member of the Alvarez Artist 60 Series. Alvarez was careful to get the construction just right to allow this series to sing, and deliver a player experience that's exceptional for a mid price instrument.The term solid top of course refers to the soundboard of an acoustic guitar being made of solid wood, rather than being laminated. However, just because the top is solid, it doesn't necessarily mean the sound automatically benefits from this feature. The tone of the instrument only improves significantly when the whole guitar is built correctly to really release the energy a solid soundboard can generate. The Artist Series is built to do exactly this.Each model is designed to get the best out if its components, and for them to work together to produce a tone and player experience, rarely found in affordable instruments.The sound is warm, open and powerful, and both the treble and bass registers are clearly present and balanced in relation to each other. These guitars feel right and are exciting to play and responsive.The solid A grade Sitka spruce tops are hand selected from quarter-sawn wood. This ensures consistent quality, and its no secret better guitars are made from better wood. These tops not only look great but they are stiff and strong and finely grained. This allows them to be cut just that tiny bit thinner, which lets them dance a little more and produce a lot more vibration, and ultimately a richer tone.All of the components are made of natural materials such as mother of pearl and abalone inlays, real bone saddles and nuts and rosewood appointments.12 String Dreadnought Acoustic Guitar Hand selected, A grade, solid Sitka spruce topHand sanded, scalloped bracingMahogany back and sidesAlvarez bi-level rosewood bridgeRosewood fingerboardPremium, high gloss finishDovetail neck jointReal bone nut and saddlePaua abalone and mother of pearl inlaysPremium die cast chrome tunersABS bindingDAddario EXPs |
|
|
Twelve Duets, K. 487 $5.95 (Arranged). By Wolfgang Amadeus Mozart (1756-1791). Duet or Duo; Masterworks; String Duo - Violin and Viola. Kalmus Edition. Classical; Masterwork. Book. 12 pages. Published by Alfred Music Publishing |
|
|
Twelve Studies, Op. 55 $8.95 By Johannes Palaschko (1877-1932). For Viola. Masterworks; String - Viola Alone. Kalmus Edition. 20th Century; Masterwork; Romantic. Book. 16 pages. Published by Alfred Music Publishing |
|
|
Twelve German Dances $9.95 (Score & Parts (arranged)). By Franz Joseph Haydn (1732-1809). Masterworks; String Trio - 2 Violins and Cello; Trio. Kalmus Edition. Classical; Masterwork. Score & Parts. 40 pages. Published by Alfred Music Publishing |
|
|
The Twelve $28.51 The Twelve is an extraordinary and unforgettable novel about a most unusual and unsuspecting hero. At fifteen years old, Max has a near-death experience during which he has a vision that reveals the names of twelve unique individuals. While Max cannot discern the significance of the twelve names, he is unable to shake the sense that they have deep meaning. Eight years pass before Max meets the first of The Twelve. With this meeting, Max's voyage of discovery begins, as he strives to uncover the identities and roles of the individuals he will meet during his journey toward truth. All of The Twelve seem connected, and all of them are important to what will happen at the exact moment the world as we know it will end. The outcome of their meeting could fulfill an ancient Mayan prophecy, controlling the future of life on our planet. Only The Twelve can provide the answers, as the fate of all humanity rests in the balance. |
|
|
Twelve Little Duets, Op. 38 $9.95 By Jacques Fereol Mazas (1782-1849). For Violin. Duet or Duo; Masterworks; String - 2 Violins. Kalmus Edition. Classical; Masterwork; Romantic. Book. 64 pages. Published by Alfred Music Publishing |
|
|
Twelve Little Duets, Op. 70 $14.99 By Jacques Fereol Mazas (1782-1849). For Violin. Duet or Duo; Masterworks; String - 2 Violins. Kalmus Edition. Classical; Masterwork; Romantic. Book. 96 pages. Published by Alfred Music Publishing |
|
|
Twelve's It $6.99 Track Listing: 1. Twelve's It, 2. Syndrome, 3. Homecoming, 4. Mozartin', 5. Orchid Blue, 6. Friendships, 7. Surrey With the Fringe on Top, The, 8. I've Grown Accustomed to Her Face, 9. Tell Me, 10. All Good Intentions, 11. Zee Blues, 12. Party's Over, The |



US $97.80
















![GERLACHFRED TWELVE STRING GUITAR FOLK SONGS BLUES SUNG PL CD R CD NEW]](http://www.geniswing.com/images/e/150823832238_0.jpg)















































![CAINEURIPNOARDITTI STRING TWELVE CAPRICES CD NEW]](http://www.geniswing.com/images/e/140700610197_0.jpg)



![KOTTKELEO SIX TWELVE STRING GUITAR CD NEW]](http://www.geniswing.com/images/e/140700091401_0.jpg)

























