How to get a string from memory into DTrace script
I have a char* in my DTrace script that I know points to a zero-terminated string. How to access this string? Is there some function like copyin() that handles zero-terminated strings? ...
I have a char* in my DTrace script that I know points to a zero-terminated string. How to access this string? Is there some function like copyin() that handles zero-terminated strings? ...
I want to find string similarity between two strings. This page ha sexmaple of some of them. Python has an implemnetation of Levenshtein algorithm. Is there a better algorithm, (and hopefully a python library), under these contraints. I want to do fuzzy matches between strings. eg matches('Hello, All you people', 'hello, all You peopl'...
int main() { char d = 'd'; std::string y("Hello worl"); y.append(d); // this fails std::cout << y; return 0; } I also tried, but also failed. int main() { char d[1] = { 'd' }; std::string y("Hello worl"); y.append(d); std::cout << y; return 0; } Sorry for this dumb question, but I've searched around google, what ...
I found myself having to remove the first line of a string quite often while working on a text parser in C#. I put together a simple function to do that for me, but coming from a PHP background, I have no idea where to put it since I can't define a function outside a class. What's a customary way of doing that in .NET? Do I create a stat...
Greetings. Imagine you've been given a string (from somewhere you can't control). In that string is a decimal number. You want to add commas (ie: turn 1234567.89 into 1,234,567.89) to that number while keeping the entire string intact. The currency symbol before the number will vary, but the comma-formatting doesn't have to vary by c...
Hello: I feel that this question has a simple answer; but, for the life of me, I could not figure it out. I am trying to convert a listbox selection to its string element so I can enter it into a database. I understand that I can use .listbox curselection to get its index; however, I need to convert it into its string. Can anyone h...
say a string might be like "a b '' c '' d", how can I check that there is single/double quote and space contained in the string? ...
String returned by string.Format seems to use some strange encoding. Spaces contained in format string are represented using different byte values compared to spaces contained in strings declared in source code. The following test case demonstrates the problem: [Test] public void FormatSize_Regression() { string size1023 = FileHelpe...
I´ve got problems with opening textures in SDL. I´ve got a function to read bmp files, optimize them and add colorkey: SDL_Surface* SDLStuff::LoadImage( char* FileName ) { printf( "Loading texture: \"%s\"\n", FileName ); SDL_Surface* loadedImage = 0; SDL_Surface* optimizedImage = 0; loadedImage = SDL_LoadBMP( FileName ); optimizedImag...
If i have char* str; how do I write a function that accepts str and can make changes to str so that, the changes persist after the function returns? what I have is: char *str = (char *) malloc(10); sprintf(str, "%s", "123456789"); //str points to 1 move_ptr(&str); //str points to 2 void move_ptr(char** str) { *str++; } is there ...
char *str = malloc (14); sprintf(str, "%s", "one|two|three"); char *token1, *token2, *token3; char *start = str; token1 = str; char *end = strchr (str, '|'); str = end + 1; end = '\0'; token2 = str; end = strchr (str, '|'); str = end + 1; end = '\0'; ... free(start); does that free work properly since I have been setting bytes wit...
Hi, I have this function which is called about 1000 times from main(). When i initialize a pointer in this function using malloc(), seg fault occurs, possibly because i did not free() it before leaving the function. Now, I tried free()ing the pointer before returning to main, but its of no use, eventually a seg fault occurs. The above...
Is there a function in c that will return the index of a char in a char array? For example something like: char values[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char find = 'E'; int index = findInedexOf( values, find ); ...
This is for a friend of mine who is having trouble with Java for school. I do know some programming, but not Java. Scanner kbReader = new Scanner(System.in); System.out.print("Name of item: "); String name = kbReader.next(); System.out.println("Original price of item: $"); double price = kbReader.nextDouble(); Outputs: Name of item:...
What's the best way in Ruby (with Rails, if relevant) to capitalize the first letter of a string? Note that String#capitalize is not what I want since, in addition to capitalizing the first letter of the string, this function makes all other characters lowercase (which I don't want -- I'd like to leave them untouched): >> "a A".capital...
I currently use the following Perl to check if a variable is defined and contains text. I have to check defined first to avoid an 'uninitialized value' warning: if (defined $name && length $name > 0) { # do something with $name } Is there a better (presumably more concise) way to write this? ...
Is it possible to attach a List of strings to a String property so that the user can select one of the strings from the Properties window? Should I implement ICollection or something of that sort? ...
Hi! I connect to a webservice that gives me a response something like this(This is not the whole string, but you get the idea): sResponse = "{\"Name\":\" Bod\u00f8\",\"homePage\":\"http:\/\/www.example.com\"}"; As you can see, the "Bod\u00f8" is not as it should be. Therefor i tried to convert the unicode (\u00f8) to char by doing this...
Hi, I'm building a page and would like to know how to extract substring from a string until finds a comma in asp.net c#. Can someone help please? Thanks, Alina ...
i have a text string in the following format $str= "word1 word2 word3 word4 " So i want to seperate each word from the string.Two words are seperated by a blank space How do i do that. IS there any built in function to do that? ...