I hope this helps . I am asking for your help with sed. I need to remove duplicate underscores and underscores from beginning and end of string. , Just add ;s/__*/_/g;s/^_//;s/_$// just after g in your sed command.
Removing duplicate characters from string using STL
To fix this issue The whole point of C++’ algorithm and container design is that the algorithms are – as far as possible – container agnostic. So the same algorithm that works on vectors works – of course! – on strings.
it should still fix some issue I've already converted the strings characters to ASCII and converted them values to binary but I'm wondering how to print the values of each character E.g if the user inputted "Hello" it would run as h,e,l,l,o in binary and print "frequency of l = 2" kind of thing .. I've written what I think could be used but anything after where I initialsie the array of size 256 is probably incorrect Any help would be much appreciated as to what I'm doing wrong , You can just print the frequency of characters only if it is not 0.
public class test2
public static void main( String args )
System.out.print( "Enter your sentence : " );
Scanner sc = new Scanner( System.in );
String name = sc.nextLine();
int array = new int;
for ( int i = 0; i < name.length(); i++ )
char character = name.charAt( i );
int ascii = ( int )character;
System.out.println( character + " = " + Integer.toBinaryString( ascii ) );
for ( int i = 0; i < array.length; i++ )
if ( array[i] > 0 )
System.out.println( "Frequency of " + (char)i + " = " + array[i] );
How to check the length/number of characters of a string inputted by a user in Octave?