I'm using boost::program_options and it suffers from the same as many other c++ libs, even std itself: It still uses C-style null-terminated strings, because nobody really likes the weak std::string.
The method in question is:
options_description_easy_init&
operator()(const char* name,
const value_semantic* s,
con...
can anyone let me know the meaning of { } [curly braces] in outputting a string ?
...
Is it possible to multiply a char by an int?
For example, I am trying to make a graph, with *'s for each time a number occurs.
So something like, but this doesn't work
char star = "*";
int num = 7;
cout << star * num //to output 7 stars
...
I need to do the following C# code in C++ (if possible). I have to const a long string with lots of freaking quotes and other stuff in it.
const String _literal = @"I can use "quotes" inside here";
...
The following code is trying to remove any duplicate characters in a string.Iam not sure if the code is right??Can anybody help me with the working of the code i.e whats actually happening when there is a match in characters?
public static void removeDuplicates(char[] str) {
if (str == null) return;
int len = str.length;
if (len <...
I have a requirement to insert a string between two markers.
Initially I get a sting (from a file stored on the server) between #DATA# and #END# using:
function getStringBetweenStrings($string,$start,$end){
$startsAt=strpos($string,$start)+strlen($start);
$endsAt=strpos($string,$end, $startsAt);
return substr($string,$startsAt,$...
I'm trying to make this command:
sed bla bla filename | awk '{printf "%s %s_entry_%.3f %.3f %.3f %.3f",$1,$3,$4,$5,$6,$7}'
But the thing is, i want the %.3f part to be variable. So in one case it could be %.3f and in another it could be %.3f %.3f %.3f. So i'll just use a static one in my example code for clarity. So if i want 4 of the...
I have a string
String mainString="///BUY/SELL///ORDERTIME///RT///QTY///BROKERAGE///NETRATE///AMOUNTRS///RATE///SCNM///";
Now I have another strings
String str1= "RT";
which should be matched only with RT which is substring of string mainString but not with ORDERTIME which is also substring of string mainString.
String str2= "RAT...
I want to convert the items to a String array or the type that I used to fill the ListBox.DataSource. The type has overridden ToString() but I can't seems to get it converted, not even to String[].
String[] a = (String[])ListBox1.Items;
Contacts[] b = (Contacts[])ListBox1.Items;
...
i have a string like this:
"o1 1232.5467 1232.5467 1232.5467 1232.5467 1232.5467 1232.5467"
How do I extract only "o1 1232.5467"?
The number of characters to be extracted are not the same always.. hence I want to extract until the second space is encountered.
...
I've got a text area on a web site that should be limited in length.
I'm allowing users to enter 255 characters, and am enforcing that limit with a Rails validation:
validates_length_of :body, :maximum => 255
At the same time, I added a javascript char counter like you see on Twitter, to give feedback to the user on how many characte...
I want to perform some action ONLY IF my string has a meaningful value. So, I tried this.
if (!myString.equals("")) {
doSomething
}
and this
if (!myString.equals(null)) {
doSomething
}
and this
if ( (!myString.equals("")) && (!myString.equals(null))) {
doSomething
}
and this
if ( (!myString.equals("")) && (myString!=null)) {
do...
Hello,
I need to read a whole file into memory and place it in a C++ std::string.
If I were to read it into a char, the answer would be very simple:
std::ifstream t;
int lenght;
t.open("file.txt"); // open input file
t.seekg(0, std::ios::end); // go to the end
length = t.tellg(); // report location (this is the leng...
I'm developing a REST service, so a request could be something like this:
/Data/Main/Table=Customers/
I need to get the segments one by one, and for each segment I will decide wich object I'm going to use, after I'll pass to that object the rest of the query so it can decide what to do next. Basically, the REST query is a path on a tre...
I have a bunch of string with special escape codes that I want to store unescaped- eg, the interpreter shows
"\\014\"\\000\"\\016smoothing\"\\011mean\"\\022color\"\\011zero@\\016"
but I want it to show (when inspected) as
"\014\"\000\"\016smoothing\"\011mean\"\022color\"\011zero@\016"
What's the method to unescape them? I imagine that ...
String string1 = "abCdefGhijklMnopQrstuvwYz";
String string2 = "ABC";
I had been using string1.startsWith(string2), which would return false in the above example, but now I need to ignore case sensitivity, and there is not a String.startsWithIgnoreCase().
Besides doing
string1.toLowerCase.startsWith(string2.toLowerCase());
is ...
I have two Ruby arrays, and I need to see if they have any values in common. I could just loop through each of the values in one array and do include?() on the other, but I'm sure there's a better way. What is it? (The arrays both hold strings.)
Thanks.
...
i have a string that looks like this -
"1AL||9CA||34CO||196WY||..."
i want to use a for loop or while loop, in which if i have an integer, it should parse this string and delete the value matching that integer.
example for above string
string = "1AL||9CA||34CO||196WY||..."
integer = 34
for
...
loop
new string = "1AL||9CA||196WY||......
I have a string in C# and would like to get text from specific line, say 65. And if file does not have so many lines I would like to get "". How to do this?
...
I need to know how i can make a string like "hello" to "Hello" using PHP?
I just need the first character to be Upper
...