string
Why I cannot cout a string?
You need to include
Unclosed Character Literal error
In Java, single quotes can only take one character, with escape if necessary. You need to use full quotation marks as follows for strings: You also used which I assume should be Note: When making char values (you’ll likely use them later) you need single quotes. For example:
Java end of file
Task: Each line will contain a non-empty string. Read until EOF. For each line, print the line number followed by a single space and the line content. Sample Input: Sample Output:
Ruby array to string conversion
I’ll join the fun with: EDIT: Some string interpolation to add the first and last single quote 😛
Simple way to repeat a string
String::repeat New in Java 11 is the method String::repeat that does exactly what you asked for: Its Javadoc says:
How can I extract a number from a string in JavaScript?
For this specific example, in the general case: Since this answer gained popularity for some reason, here’s a bonus: regex generator. Expand snippet
Fastest way to Convert String to Binary?
Using std::bitset would work: Output:
How do I remove the file suffix and path portion from a path string in Bash?
Here’s how to do it with the # and % operators in Bash. ${x%.bar} could also be ${x%.*} to remove everything after a dot or ${x%%.*} to remove everything after the first dot. Example: Documentation can be found in the Bash manual. Look for ${parameter%word} and ${parameter%%word} trailing portion matching section.
Lua read beginning of a string
Have a look at this page http://lua-users.org/wiki/StringRecipes: Then use