I have a C++ application that embeds the Python interpreter. It calls PyImport_Import to load scripts. I need a way of getting any syntax errors as C strings. For example, if the script uses a undefined function, I would like an error saying something like 'Function xxx is undefined.' How would I do this?
...
How would you convert a string like that to an associative array in PHP?
key1="value" key2="2nd value" key3="3rd value"
...
Hi,
I'm storing some classes with WideString parameters describing them (like name, description and some others). Now if I change all those WideStrings to simple "string" (I'm using alias actually so I have to change one line only), memory usage is about 5% bigger!! than previously...
How is that possible, since each char of the string i...
Hello,
Assume that there is an object, passed as an argument to a function. the argument name is "obj".
can it be concatenated as followed?
$(obj + " .className")......
OR
$(obj + "[name='obj_name'])......
Thanks.
...
I have a library which needs to parse double numbers which always use a point '.' as decimal separator. Unfortunately for this case, strtod() respects the locale which might use a different separator and thus parsing can fail. I can't setlocale() - it isn't thread-safe. So I'm searching for a clean locale-independent strtod implementatio...
string::iterator it;
for (it = str.begin(); it < str.end(); it++)
cout << *it;
cout << endl;
Why not:
for (int i = 0; i < str.size(); i++)
cout << str[i];
cout << endl;
It seems that string::iterator does not provide range check either. Why should we use string::iterator rather than index?
Thanks.
...
void permute(string elems, int mid, int end)
{
static int count;
if (mid == end) {
cout << ++count << " : " << elems << endl;
return ;
}
else {
for (int i = mid; i <= end; i++) {
swap(elems, mid, i);
permute(elems, mid + 1, end);
swap(elems, mid, i);
}
}
...
I have an MFC application in C++ that uses std::string and std::wstring, and frequently casts from one to the other, and a whole lot of other nonsense. I need to standardize everything to a single format, so I was wondering if I should go with CString or std::wstring.
In the application, I'll need to generate strings from a string tabl...
Is there a way to convert the string from a text field to a double in j2me? And what is the name of the string that comes out of the text field?
...
I am currently writing a program that will read part of the windows system registry however some of the values of these keys are of type System.Byte[] when i try and decode these values I can produce a string that has some readable characters that makes but mostly the string is jiberish. I have tried several encoding types but none seem ...
I'm working through a Python 3 book and came across the string function isidentifier(). The text description is "s.isidentifier() : Returns True if s is non empty and is a valid identifier". I tested it in the Python Shell like this:
>>> s = 'test'
>>> s.isidentifier()
True
>>> 'blah'.isidentifier()
True
I would expect the 2nd state...
I have an enum:
public enum Color
{
Red,
Blue,
Green,
}
Now if I read those colors as literal strings from an XML file, how can I convert it to the enum type Color.
class TestClass
{
public Color testColor = Color.Red;
}
Now when setting that attribute by using a literal string like so, I get a very harsh warning f...
I am using strpos() to find the needle in the haystack. But, I want it to only find the needle with the same string length. E.g.:
$mystring = '123/abc';
$findme = 'abc';
$pos = strpos($mystring, $findme); // THIS IS FINE
$mystring = '123/abcdefghijk';
$findme = 'abc';
$pos = strpos($mystring, $findme); // THIS IS NOT FINE
So, I...
I'm solving this K&R exercise:
Write versions of the library functions strncpy , strncat , and strncmp , which operate on at most the first n characters of their argument strings. For example, strncpy(s,t,n) copies at most n characters of t to s . Full descriptions are in Appendix B.
So i was wandering if there's a site that contains s...
I have written the following code which will does not work but the second snippet will when I change it.
int main( int argc, char *argv[] )
{
if( argv[ 1 ] == "-i" ) //This is what does not work
//Do Something
}
But if I write the code like so this will work.
int main( int argc, char *argv[] )
{
string opti = "-i";
if( ...
It is UTF-8.
For example, 情報 is 2 characters while ラリー ペイジ is 6 characters.
...
Hi,
I am creating an application which will send the input string to mobile device. Some devices have problems with encoding special characters so I would like to create a filter which doesn't allow the user on PC to enter special characters.
The application is written in C# (.NET 3.5) and I would like to attach a method to key press e...
Do you know any solution for building string filters based on human input in PHP?
E.g.
foo and bar -zoo (like in search enginies)
is converted to regex similar to this: .*(foo|bar).*^(zoo).*.
I have found this class,
but this is not exactly what I am looking for.
...
If I have a string 'x=10', how can I extract the 10 as an integer using one line of code?
...
I am trying to convert a string into datetime with the following C# code,
DateTime dTo = DateTime.ParseExact(dateTo, "mm/dd/yyyy", CultureInfo.InvariantCulture);
eachtime I pass dateTo as 1/1/2010 it fails, instead it needs the string to be 01/01/2010.
What string format should I use to support both 01/01/2010 and 1/1/2010?
...