string

c++ - convert pointer string to integer

I am trying to convert treePtr->item.getInvest() which contains a string to an integer. Is this possible? ...

F#: Remove the first N characters from a string?

I'm trying to write some code to remove the first N characters in a string. I could have done this in an imperative manner already, but I would like to see it done in the spirit of functional programming. Being new to F# and functional programming, I'm having some trouble... ...

php mysql query syntax question regarding ""'s

Forgive me, I'm a beginner. The following code returns a parse error: $query = "INSERT INTO scenario_needgames VALUES ("$id", "Battle of the Bulge")"; the query builder in phpMyAdmin gave me this slightly modified string that works: $query = "INSERT INTO scenario_needgames VALUES (\"$id\" , \"Battle of the Bulge\");"; but I'm confu...

128-bit type error

Hi, Thanks to pbos help and its program (published here, for xoring a big file), I performed some tests and I see that I have another problem: having changed the mask by another one of 128-bit, there is no default type as big as needed. I think a solution can be to include a library to increase available integer types... but rather tha...

JS: Check if var has "cheese" OR "cake" in it?

How can i check if a variable has something in it? I tried checking if a .match() returned null but that wasn't useful for checking with an OR? All ideas would be gratefully appreciated! ...

Pretending .NET strings are value type

In .NET, strings are immutable and are reference type variables. This often comes as a surprise to newer .NET developers who may mistake them for value type objects due to their behavior. However, other than the practice of using StringBuilder for long concatenation esp. in loops, is there any reason in practice that one needs to know th...

Converting a Scheme expression to a string

Given an expression '(lambda (x) x) How can I translate this into a string. I thought symbol->string will do the job but no it cant not a symbol. e.g for a macro to-string: (to-string (lambda(x) x)) this should return >> "(lambda (x) x)" Any ideas folks Thanks ...

C#: String.Equals vs. ==

I recently was introduced to a large codebase and noticed all string comparisons are done using String.Equals() instead of ==. What's the reason for this, do you think? ...

how to get Region using Specified string in GoogleMaps in Iphone?

Hi, In my iphone application i am using MKMapView to display any region(i.e Australia) and it is working fine using coordinates(latitude and longitude).But i want to display the region based on the string (i.e Australia) instead of the coordinates. Lets say i click on the TableView with named string as "Australia" and in the next view i...

Replace last string

I want to replace the last String which is a "," with ")" Suppose the string is Insert into dual (name,date, to be converted to Insert into dual(name,date) ...

Shared string in C++ ?

Which "shared string" implementation for C++ would you recommend? (Sorry if I missed a similar question. I had a look but could not find any) ...

String comparison - strA.ToLower()==strB.ToLower() or strA.Equals(strB,StringComparisonType)?

As per title, what practise for string comparisons do you use and why? ...

What is a good 64bit hash function in Java for textual strings?

I'm looking for a hash function that: Hashes textual strings well (e.g. few collisions) Is written in Java, and widely used Bonus: works on several fields (instead of me concatenating them and applying the hash on the concatenated string) Bonus: Has a 128-bit variant. Bonus: Not CPU intensive. ...

How to do Erlang pattern matching using regular expressions?

When I write Erlang programs which do text parsing, I frequently run into situations where I would love to do a pattern match using a regular expression. For example, I wish I could do something like this, where ~ is a "made up" regular expression matching operator: my_function(String ~ ["^[A-Za-z]+[A-Za-z0-9]*$"]) -> .... I know...

How do I declare a string without assigning a value in C++?

I know that for an integer, you can use: int value; I tried: string str; but Visual C++ gave me an error. How do I declare it without assigning a value, then using cin >> str later on to assign it? ...

Why doesn't Perl support the normal [] operator to index a string?

Why doesn't Perl support the normal [] operator to index a string? Almost all major programming languages support this operator,esp the other two 'P': python and php.Moreover,I do think it should be easy to implementate this little syntax.Also,as the philosophy of the perl programming language -- as lazy as we could,so why do we bother t...

replacing escape character sequences in objective c

I have a query that returns a string, as well as an escape character sequence. (ex. "USA\"") I am using stringByReplacingOccurrencesOfString in this fashion: [theCountry stringByReplacingOccurrencesOfString:@"\"" withString:@""]; But it is still leaving behind a set of quotes. and if I were to try the method again to remove them: [...

c++: ifstream open problem with passing a string for text file name

hi guys, i'm trying to pass a string from main to another function. this string is a name of text file that needs to be oepened. as far as i can see, i am passing the string alright, but when i try to use ifstream.open(textFileName), it doesn't quite work. but when i manually hardcode it as ifstream.open("foo.txt"), it works just fine. i...

Reading a file into an array

I would like to read a text file and input its contents into an array. Then I would like to show the contents of the array in the command line. My idea is to open the file using: inFile.open("pigData.txt") And then to get the contents of the file using: inFile >> myarray [size] And then show the contents using a for loop. My prob...

How to create an image from a string in python

Hi, I'm currently having trouble creating an image from a binary string of data in my Python program. I receive the binary data via a socket but when I try the methods I read about on here like this: buff = StringIO.StringIO() #buffer where image is stored #Then I concatenate data by doing a buff.write(data) #the data from the socket...