Substring/Top and tail: Difference between revisions
Content added Content deleted
m ({{omit from|Openscad}}) |
No edit summary |
||
Line 100: | Line 100: | ||
ANSI C provides little functionality for text manipulation outside of string.h. While a number of libraries for this purpose have been written, this example uses only ANSI C. |
ANSI C provides little functionality for text manipulation outside of string.h. While a number of libraries for this purpose have been written, this example uses only ANSI C. |
||
=={{header|C++}}== |
|||
<lang C++>#include <string> |
|||
#include <iostream> |
|||
int main( ) { |
|||
std::string word( "Premier League" ) ; |
|||
std::cout << "Without first letter: " << word.substr( 1 ) << " !\n" ; |
|||
std::cout << "Without last letter: " << word.substr( 0 , word.length( ) - 1 ) << " !\n" ; |
|||
std::cout << "Without first and last letter: " << word.substr( 1 , word.length( ) - 2 ) << " !\n" ; |
|||
return 0 ; |
|||
}</lang> |
|||
Output: |
|||
<PRE>Without first letter: remier League ! |
|||
Without last letter: Premier Leagu ! |
|||
Without first and last letter: remier Leagu ! |
|||
</PRE> |
|||
=={{header|C sharp}}== |
=={{header|C sharp}}== |