I just took an exam where i was asked the following:
Write the function body of each of the methods GenStrLen, InsertChar and StrReverse for the given code bellow. You must take into consideration the following;
How strings are constructed in C++
The string must not overflow
Insertion of character increases its length by ...
Similar questions have been brought (good speed comparison there) on this same subject. Hopefully this question is different and updated to Python 2.6 and 3.0.
So far I believe the faster and most compatible method (among different Python versions) is the plain simple + sign:
text = "whatever" + " you " + SAY
But I keep hearing and r...
Can someone help me complete this PHP function? I want to take a string like this: 'this-is-a-string' and convert it to this: 'thisIsAString':
function dashesToCamelCase($string, $capitalizeFirstCharacter = false) {
// Do stuff
return $string;
}
...
fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
I don't want to output anything via fprintf,but only the result of "Error in pcap_findalldevs: %s\n", errbuf,what's the function for that?
...
@string = "Sometimes some stupid people say some stupid words"
@string.enclose_in_brackets("some") # => "Sometimes {some} stupid people say {some} stupid words"
How should the method enclose_in_brackets look ? Please keep in mind, I want only enclose whole words, (I don't want "{Some}times {some} stupid....", the "sometimes" word shou...
I am communicating with a server who needs null terminated string
How can I do this smartly in C#?
...
I want to replace the inner_text in all paragraphs in my XHTML document.
I know I can get all text with Nokogiri like this
doc.xpath("//text()")
But I want only operate on text in paragraphs, how I can select all text in paragraphs without affecting eventually existent anchor texts in links ?
#For example : <p>some text <a href="/">...
Hi folks
Looking for suggestions as to the best way to do this (I know there are many options):
take a variable like this:
$args = ('post_type=post&order_by=DESC&limit=10');
the create a function to convert that variable into parts like this:
$post_type = post;
$order_by = DESC;
$limit= 10;
Reason is I want a client to be able to...
I have a file which contains three integers per line. When I read the line I use a stringstream to separate the values, but it only reads the first value as it is. The other two are read as zero's.
ifstream inputstream(filename.c_str());
if( inputstream.is_open() ){
string line;
stringstream ss;
while( getline(inputstream...
My current project requires locating an array of strings within an element's text content, then wrapping those matching strings in <a> elements using JavaScript (requirements simplified here for clarity). I need to avoid jQuery if at all possible - at least including the full library.
For example, given this block of HTML:
<div>
<p>T...
I need to check in string.Endswith("") from any of the following operators: "+,-,*,/"
If I have 20 operators I don't want to use "||" operator 19 times.
...
I've seen questions to prefix zeros here in SO. But not the other way !!
Can you guys suggest me how to remove the leading zeros in alphanumeric text. Are there any built-in APIs or do I need to write a method to trim the leading zero's?
Example:
01234 converts to 1234
0001234a converts to 1234a
001234-a converts to 1234-a
101234 rema...
Hello all,
I am trying to parse some data and just started reading up on regular Expressions so I am pretty new to it. This is the code I have so far
String = "MEASUREMENT 3835 303 Oxygen: 235.78 Saturation: 90.51 Temperature: 24.41 DPhase: 33.07 BPhase: 29.56 RPhase: 0.00 BAmp: 368.57 BPot: ...
How can I remove <table>, <tr>, and <td> HTML tags plus non-ASCII characters from a string using C#?
I want to leave other tags in the string alone.
...
My .net application does some heavy string loading/manipulation and unfortunately the memory consumption keeps rising and rising and when looking at it with a profiler I see alot of unreleased string instances. Now at one point of time or another I do need all objects t hat do have these string fields, but once done, I could get rid of e...
I have a version number with 3 digits as a String,
var version = "1.2.3";
and would like to compare it to another version. To see if version is newer than otherversion,
var otherVersion = "1.2.4";
How would you do it?
...
I have a string like
def data = "session=234567893egshdjchasd&userId=12345673456&timeOut=1800000"
I want to convert it to a map
["session", 234567893egshdjchasd]
["userId", 12345673456]
["timeout", 1800000]
This is the current way I am doing it,
def map = [:]
data.splitEachLine("&"){
it.each{ x ->
def object = x.s...
I have a following string that I would like to parse into either a List or a String[].
(Test)(Testing (Value))
End result should be Test and Testing (Value)
...
Suppose I have this:
My---sun--is------very-big---.
I want to replace all multiple hyphens with just one hyphen.
...
I'm trying to check whether or not the second argument in my program is a substring of the first argument. The problem is that it only work if the substring starts with the same letter of the string.
EDIT: It must be done in C, not C++. Sorry
int main(int argc, char **argv){
if (argc != 3) {
printf ("Usage: check <string o...