string to integer
I can't do this in C++ string temp = "123"; int t = atoi(temp); why???? ...
I can't do this in C++ string temp = "123"; int t = atoi(temp); why???? ...
I am trying to return the index's to all occurrences of a specific character in a string using Ruby. A example string is "a#asg#sdfg#d##" and the expected return is [1,5,10,12,13] when seaching for # characters. The following code does the job but there must be a simpler way of doing this? def occurances (line) index = 0 all_index ...
What is the best way to replace characters in a string? Specifically: "This,Is A|Test" ----> "This_Is_A_Test" I want to replace all commas, spaces, and "|" with underscores. (I have access to Boost.) ...
What is the simplest method to remove the last character from the end of a String in Scala? I find Rubys String class has some very useful methods like chop. I would have used "oddoneoutz".headOption in Scala, but it is depreciated. I don't want to get into the overly complex: string.slice(0, string.length - 1) Please someone tell me...
In C#, I have an array of ints, containing digits only. I want to convert this array to string. Array example: int[] arr = {0,1,2,3,0,1}; How can I convert this to a string formatted as: "012301"? ...
Hi, I thought a C string can be initialized with one and only one quoted string. I just wonder how is this correct? char const help_message [] = "Usage: %s [options] files ...\n" "\n" "Options include:\n" " --verbose -v Be verbose\n" " --help -h Print this help message\n" " --output -o ...
If I'm turning a ruby hash into a string of name-value pairs (to be used in HTTP params, for example), is this the best way? # Define the hash fields = {"a" => "foo", "b" => "bar"} # Turn it into the name-value string http_params = fields.map{|k,v| "#{k}=#{v}"}.join('&') I guess my question is: Is there an easier way to get to http_...
what i have works, but im looking if there is a faster way to copy a string into a pByteArray from sysutils PByteArray = ^TByteArray; TByteArray = array[0..32767] of Byte; assume a and s are setup correctly a: pByteArray; s: string; is there a fast way to do this, ie something like copy for i := 1 TO Length(s) - 1 do ...
Hi, my Ruby On Rails unit-test fails in a simple string comparison and I can't figure out why. In the model TestItem, I have doc = REXML::Document.new(data) @bugtitle = doc.root.get_text("/bugzilla/bug/short_desc") where data is a xml-string returned by a Net::HTTP::post request. The data looks good, and if I output @bugtitle it cont...
Hello everyone there... I have a problem, suppose I have a given string: "best", the target string is suppose: "beast". Then I have to determine the number of operations to convert the given string to the target string, however the operations allowed are: 1. add a character to string. 2. delete a character. 3. swap two char positions. (...
Can strings be used as template arguments? I tried: template <char *str> struct X { const char *GetString() const { return str; } }; int main() { X<"String"> x; cout<<x.GetString(); } And although I get no complaints about the class definition, the instantiation yeilds 'X' : invalid expression as a templ...
Hi All, I would really appreciate if somebody could help me/offer advice on this. I have a file, probably about 50000 lines long, these files are generated on a weekly basis. each line is identical in terms of type of content. original file: address^name^notes but i need to perform a switch. i need to be able to switch (on each and...
I'm reading a file in C++ using streams, specifically, fstream, not ifstream. blah blah blah\n blah blah\n blah blah blah blah \n end This repeats over and over with varble number of blah's in each line, constant number of lines between each end, end is the delimiter here I want to read one set of data, then store it in a characte...
I'm looking for a quick way (in C#) to determine if a string is a valid variable name. My first intuition is to whip up some regex to do it, but I'm wondering if there's a better way to do it. Like maybe some kind of a secret method hidden deep somewhere called IsThisAValidVariableName(string name), or some other slick way to do it tha...
Hey guys, I have this quick problem I need to solve. I have a string here like so: textbox.text =@"Your name is" then I want to add right after "your name is" a variable that displays text. so in Visual Basic I learned it like this... textbox.text =@"Your name is" & variable1. but now i can see that it doesn't work like that in c...
Hi, Im having trouble matching the format of a string, the format is that of the .srt timing which is "00:00:01,000 --> 00:00:04,000", hour,minutes,seconds,mili seconds. how do I match this in a string? Im trying to add and subtract the time here. ...
When the following code is run: Response.Write("window.open('BugSummaryForPrint.aspx?prjId=" + prjId + "&prjName=" + prjName','_blank')"); I get this error: Newline in constant Help! ...
hi all, i'm having NSMutableArray which containing student info, now i just want to extract student name and their average mark only, so what i did NSMutableArray *stuCollection = [[NSMutableArray alloc] initWithCapacity:[students count]]; for (int i = 0; i < [students count]; i++) { if([students objectAtIndex:i] != NULL) { N...
Hello all, this is my first post. I am selecting some fields from a database which are numeric id values e.g. 10,20,100,110 etc. These numbers actually mean something meaningful such as area. Ideally there should be a look up database table with matching ID and name field but there isnt and it has now become difficult to implement in ...
I need to search a specific column for every occurrence of a string and replace it with a different string. The column is a MySQL TEXT column. ...