string

Concatenating strings in macros - C++

What's the easiest way to concatenate strings defined in macros. i.e. The pseudo code I'm looking for would be like: #define ROOT_PATH "/home/david/" #define INPUT_FILE_A ROOT_PATH+"data/inputA.bin" #define INPUT_FILE_B ROOT_PATH+"data/inputB.bin" ... #define INPUT_FILE_Z ROOT_PATH+"data/inputZ.bin" The only way I know of is to use st...

What does an upside down question mark mean in the output in C?

Hi, I get an upside down question mark as an output from of of my function, what does it mean exactly? ...

What is the max length of a python string?

If it is environment-independent, what is the theoretical maximum number of characters in a python string? Also if it differs with version number I'd like to know it for python 2.5.2 ...

Creating a FILE * stream that results in a string

I'm looking for a way to pass in a FILE * to some function so that the function can write to it with fprintf. This is easy if I want the output to turn up in an actual file on disk, say. But what I'd like instead is to get all the output as a string (char *). The kind of API I'd like is: /** Create a FILE object that will direct writ...

C#: How to split this string

I have some strings, entered by users, that may look like this: ++7 7++ 1++7 1+7 1++7+10++15+20+30++ Those are to mean: Anything up to and including 7 Anything from 7 and up 1 and 7 and anything inbetween 1 and 7 only 1 to 7, 10 to 15, 20 and 30 and above I need to parse those strings into actual ranges. That is I need to create ...

Any way to calculate the pixel length of a string?

I'm using the GD library for PHP, and using functions like imagestring() and imagestringup() to add text to pictures. I am using the built-in fonts with latin2 encoding. Is there a way, with a given string, to calculate the length (in pixels) of the string? I want to calculate the length in pixels of the strings because the strings ...

Convert float to string with cutting zero decimals afer point in Python

Hi all! I am feeling difficult to convert a float to string in the following manner: 20.02 --> 20.02 20.016 --> 20.02 20.0 --> 20 Seems "%g" format is the best for that, but I am getting strange results: In [30]: "%.2g" % 20.03 Out[30]: '20' In [31]: "%.2g" % 20.1 Out[31]: '20' In [32]: "%.2g" % 20.3 Out[32]: '20' In [33]: "%....

String (C++) in XCode

Does anyone know why in XCode, when you do something simple like string str; cout << "input string"; getline(cin, str); cout << str; you would get malloc: *** error for object 01x100000240: pointer being freed was not allocated error? thanks. ...

how to detect links in a string using RegEx in as3 ?

I am trying to find the generic links in strings. I've found a very handy regex on RegExr, in the community expressions: (https?://)?(www\.)?([a-zA-Z0-9_%]*)\b\.[a-z]{2,4}(\.[a-z]{2})?((/[a-zA-Z0-9_%]*)+)?(\.[a-z]*)?(:\d{1,5})? I tried to use it and it returns null, although the same string tested on RegExr works fine: var linkRegEx:...

Java String Encoding to UTF-8

Hi All, I have some HTML code that I store in a Java.lang.String variable. I write that variable to a file and set the encoding to UTF-8 when writing the contents of the string variable to the file on the filesystem. I open up that file and everything looks great e.g. shows up as a right arrow. However, if the same String (containing ...

insert a hyphen into a string C++

i have an array of strings of phone numbers, and i have to insert hyphens into them. what string function should i use, and how? thanks. :D ...

how to store printf into a variable?

I want to store a formatted string using something similar to what printf does in C. char *tmp = (char *)sqlite3_column_text(selectstmt, 2); const char *sqlAnswers = printf("select key from answer WHERE key = %s LIMIT 5;", tmp); The following is an error obviously, I am sure alot of c programmers out there would give me a quick answer...

advanced string management and completion C#

Hello, Alright, so im going to jump in with my situation: so i have string[] MyStringArray with "hello", "goodbye", "morning" in it, and now i have a normal string MatchString = "hel", now, on a specific trigger, id like to be able to loop through the strings in MyStringArray, and find the most likely match, and replace. so for instanc...

Using C, convert a dynamically-allocated int array to a comma-separated string as cleanly as possible

I’m much less experienced in C than I am in higher-level languages. At Cisco, we use C, and I sometimes run into something that would be easy to do in Java or Python, but very difficult to do in C. Now is one of those times. I have a dynamically-allocated array of unsigned integers which I need to convert to a comma-separated string for...

Implementing a string class that does case insensitive comparisions in Scala

I've got a number of classes with fields that are meant to be case insensitive, and I'd like to put the instances of these classes into HashMaps and look them up by string case insensitive. Instead of using toLowerCase every time I want to index an instance by its string, or look up an instance by its string, I've instead tried encapsul...

problem with stringtokenizer

Hi all, i want to parse the following using StringTokenizer for every string matching "agent>". I tried it using the code like this. Please let me know where i am going wrong. StringTokenizer stringtokenizer=new StringTokenize(hari,"agent>"); while(stringtokenizer.hasMoreTokens()) { String token = stringtokenizer.nextToken(); ...

Is searching a HashTable slower when the key are strings and the strings contain spaces

Today I was discussing with another developer about a limitation in a third party library, where we couldn't use spaces in a string. The reasoning was that the strings were used as keys in a .NET Hashtable, and that searching a .NET HashTable was significantly slower when the keys contained spaces. Now since I'm too lazy to write a test...

C# += (plus equals) (Assignment by addition) working very slow, when string is too long?

Hello, I have a for loop and what I do is this. forloop ( loop 7000 times) { x += 2000_char_long_string; } Code lasts really long time in this forloop, maybe more than 1 minute. How can I solve this problem? Thanks. ...

C#: Anything similar to the php ctype_digit function for C#?

I have a string and I want to check that it only consists of digits. I don't really want to (or need to) parse it or anything, I just want to know that it does not contain anything but digits (and no floating point separator either, just digits). PHP has this nice function called ctype_digit. Is there anything similar for C# anywhere in...

How to convert a date String into the right format in Java?

Can somebody please explain to me how I can convert 2009-10-27 14:36:59.580250 into 27.10.2009, 14:36 ? The first date is available as a string and the second one should be a string as well ;) Up to now I'm not so into date conversion within Java... Thanks in advance! ...