i try to compare between 2 char* identical strings,but one of them contains a null terminator at the end.
i've been looking through the internet and understood that it's not recommendable to remove the null terminator char cause it will make the string unstable.
what other methods can i use?
the comparing function:
int StringCompare(co...
I have a string with some spaces in it, and would like to split on the last space, and return the part of the string before that space. Does Postgres support this? I have not been able to solve this with the usual split_part-type functions.
Example : "fort worth tx" -> "fort worth"
...
I need to make a decision about a string based on the first character, and I have a method defined in this way:
(defn check-first [string]
(case (get string 0)
"+" 1
"-" 2
3
))
Currently it always returns 3 even when the string starts with those characters. What am I doing wrong? Also, is there a more elegant way to ...
When I split the string "1|2|3|4" using the String.split("|") I get 8 elements in the array instead of 4. If I use "\\|" the result is proper. I am guessing this has something todo with regular expressions. Can anybody explain this?
...
Say I have a string like:
string hex = "48656c6c6f";
Where every two characters correspond to the hex representation of their ASCII, value, eg:
0x48 0x65 0x6c 0x6c 0x6f = "Hello"
So how can I get "hello" from "48656c6c6f" without having to create a lookup ASCII table? atoi() obviously won't work here.
...
Hi,
Maybe it's because it's end of day on a Friday, and I have already found a work-around, but this is killing me.
I am using Java but am .NET developer.
I have a string and I need to split it on semicolon comma. Let's say its a row in a CSV file who has 200 210 columns. line.split(',').length will be sometimes, 199, where count of '...
I'm trying to create a Ruby Hash of objects, where the keys are the object @name member:
# m is an object with an @name instance variable (a string)
myHash = {}
myHash[m.name] = m
It's giving this error:
#<TypeError: can't convert String into Integer>
Anyone know why? I'm sure that m.name is a valid string...
...
When I try to pass a string to a function like so
i="file:///bla/bla/bla";
Fade(i);
i get Uncaught SyntaxError: Unexpected token :
so i tried passing a literal in the function like f("img1.jpg");
and i got
Uncaught ReferenceError: img1 is not defined
(anonymous function)
What is going on?
(note that i am kind of new in js)
In pa...
I have a MySQL table ( members ) with six columns ( FirstName, LastName, Email, username, password, Key)
I need to insert a string into the Key column for the username admin
How would I go about doing this?
...
In Haskell, in order to represent the literal string "\", one would normally write:
"\\"
However, is there a way to escape the string such that a single backslash can be written by itself without needing to be escaped? For example, I can do exactly this in C# by pre-pending @ to the string:
@"\"
Does Haskell have an equivalent?
...
I want to convert a string into a signed int. Following is the requirement. I have stored hex value as a string in buffer. Now I want to convert that value into signed int.
buf = "fb869e" Convert this into signed int. So o/p should be -293218. but when I'm trying to convert using strtol I'm getting 16483998. So what I should I do?
...
char * recursivecombo(char *str, int choices, int level)
{
int len = strlen(str);
level++;
if( level == choices)
{
for (int i = 0; i < len -2; i++)
{
printf("%c", str[i]) ;
}
}
else
{
for (int i = 0; i < len - 2; i++)
{ ...
Possible Duplicate:
How to convert this code to use string
I have a function like this:
char *foo()
{
}
How can I make it return a string instead? I tried
string foo()
{
}
but the compiler complains.
...
If I type
'
into my search bar I get a mysql error as the "sting" has not been escaped- it think.
But the reason why I cant escape it is because I dont think it currently is a string.
the search box generates search results dynamically with ajax it is as I type and it finds the results that I get the error:
You have an err...
I want to replace all the occurances of ' in a string to ^, but i saw string.replace is not the right function for me, do I need to write my own? It's boring.
...
stack <char> stck;
string str;
stck.push('0');
str.append("test:");
//test:
cout << str << endl;
str.append(&stck.top());
//test:0═══════════════¤¤¤¤▌▌▌▌,╘╥XЕ┤
cout << str << endl;
Why is this happening?
...
I'm brand new to C and am trying to learn how to take a string and print it using a function. I see examples everywhere using while(ch = getchar(), ch >= 0), but as soon as I put it into a function (instead of main()), it ceases to work. Right now, it's stuck in an endless loop... why is that?
// from main():
// printString("hello");
v...
How can I convert .strings files to and from .po and .pot files?
...
This is Delphi 2009, so Unicode applies.
I had some code that was loading strings from a buffer into a StringList as follows:
var Buffer: TBytes; RecStart, RecEnd: PChar; S: string;
FileStream.Read(Buffer[0], Size);
repeat
... find next record RecStart and RecEnd that point into the buffer;
...
I'm writing a program that converts a binary string to decimal. I wanted to validate my output before I get really started on this method. I have the following code:
int get_val()
{
int sum =0;
for(int num_bits = size; num_bits>0; num_bits--)
{
printf("String sub %i is %i\n", num_bits, int(bin[num...