Search Results

Search found 1794 results on 72 pages for 'bytecode manipulation'.

Page 36/72 | < Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >

  • C++ sort array of strings

    - by user69514
    I am trying to sort an array of strings, but it's not sorting anything.... what am I doing wrong? string namesS[MAX_NAMES]; int compare (const void * a, const void * b){ return ( *(char*)a - *(char*)b ); } void sortNames(){ qsort(namesS, MAX_NAMES, sizeof(string), compare); }

    Read the article

  • .NET Format a string with fixed spaces

    - by treant
    Does the .NET String.Format method allow placement of a string at a fixed position within a fixed length string. " String Goes Here" " String Goes Here " "String Goes Here " How is this done using .NET? Edit - I have tried Format/PadLeft/PadRight to death. They do not work. I don't know why. I ended up writing my own function to do this. Edit - I made a mistake and used a colon instead of a comma in the format specifier. Should be "{0,20}". Thanks for all of the excellent and correct answers.

    Read the article

  • C Population Count of unsigned 64-bit integer with a maximum value of 15

    - by BitTwiddler1011
    I use a population count (hamming weight) function intensively in a windows c application and have to optimize it as much as possible in order to boost performance. More than half the cases where I use the function I only need to know the value to a maximum of 15. The software will run on a wide range of processors, both old and new. I already make use of the POPCNT instruction when Intel's SSE4.2 or AMD's SSE4a is present, but would like to optimize the software implementation (used as a fall back if no SSE4 is present) as much as possible. Currently I have the following software implementation of the function: inline int population_count64(unsigned __int64 w) { w -= (w 1) & 0x5555555555555555ULL; w = (w & 0x3333333333333333ULL) + ((w 2) & 0x3333333333333333ULL); w = (w + (w 4)) & 0x0f0f0f0f0f0f0f0fULL; return int(w * 0x0101010101010101ULL) 56; } So to summarize: (1) I would like to know if it is possible to optimize this for the case when I only want to know the value to a maximum of 15. (2) Is there a faster software implementation (for both Intel and AMD CPU's) than the function above?

    Read the article

  • What's the best way to parse an Address field using t-sql or SSIS?

    - by dtaylo04
    I have a data set that I import into a SQL table every night. One field is 'Address_3' and contains the City, State, Zip and Country fields. However, this data isn't standardized. How can I best parse the data that is currently going into 1 field into individual fields. Here are some examples of the data I might receive: 'INDIANAPOLIS, IN 46268 US' 'INDIANAPOLIS, IN 46268-1234 US' 'INDIANAPOLIS, IN 46268-1234' 'INDIANAPOLIS, IN 46268' Thanks in advance! David

    Read the article

  • String update in SQL Server

    - by Thiyaneshwaran S
    Currently I have varchar field. The delimiter is "$P$P$". The delimiter will appear at least once and at most twice in the varchar data. Eg. Sample Heading$P$P$Sample description$P$P$Sample conclusion Sample Heading$P$P$Sample Description If the delimiter appears twice, I need to insert a text before the second occurance of the delimiter. Eg: Sample Heading$P$P$Sample DescriptionINSERT TEXT HERE$P$P$Sample Conclusion If the delimiter occurs only once, then I need to insert a text at the end of the field. Eg: Sample Heading$P$P$Sample DescriptionAPPEND TEXT HERE How this can be done in SQL query?

    Read the article

  • How to optimize this simple function which translates input bits into words?

    - by psihodelia
    I have written a function which reads an input buffer of bytes and produces an output buffer of words where every word can be either 0x0081 for each ON bit of the input buffer or 0x007F for each OFF bit. The length of the input buffer is given. Both arrays have enough physical place. I also have about 2Kbyte free RAM which I can use for lookup tables or so. Now, I found that this function is my bottleneck in a real time application. It will be called very frequently. Can you please suggest a way how to optimize this function? I see one possibility could be to use only one buffer and do in-place substitution. void inline BitsToWords(int8 *pc_BufIn, int16 *pw_BufOut, int32 BufInLen) { int32 i,j,z=0; for(i=0; i<BufInLen; i++) { for(j=0; j<8; j++, z++) { pw_BufOut[z] = ( ((pc_BufIn[i] >> (7-j))&0x01) == 1? 0x0081: 0x007f ); } } } Please do not offer any compiler specific or CPU/Hardware specific optimization, because it is a multi-platform project.

    Read the article

  • Removing the last character of a string IF it is $variable

    - by KeenLearner
    Hi there, I've made a little script to convert titles into url friendly things. ie: 'I am a title' becomes 'I_am_a_title' My script basically goes through and turns spaces, apostrophes, commas etc etc into an underscore. The problem is, sometimes my url's end up like this: 'i_am_a_title_' with a trailing underscore... So i figure, add a little bit to go through and search to see if the last character is an underscore on the final result, and if it is, then swap it. I looked into the strrchr() function but I seem to be hitting a wall of my own understanding. How is this sort of thing accomplished?

    Read the article

  • clever way to conditionally split this string?

    - by sprugman
    I've got a string that could be in one of two forms: prefix=key=value (which could have any characters, including '=') or key=value So I need to split it either on the first or second equals sign, based on a boolean that gets set elsewhere. I'm doing this: if ($split_on_second) { $parts = explode('=', $str, 3); $key = $parts[0] . '=' . $parts[1]; $val = $parts[2]; } else { $parts = explode('=', $str, 2); $key = $parts[0]; $val = $parts[1]; } Which should work, but feels inelegant. Got any better ideas in php? (I imagine there's a regex-ninja way to do it, but I'm not a regex-ninja.;-)

    Read the article

  • How to Concatenate 2 C strings, without overwriting any terminating Null characters?

    - by Ben313
    Hello, I am trying to set up a list of file names for a parameter to SHFileOperation. I want to be able to concatenate a file name onto the char array, but i dont want to get rid of the terminating character. for example, I want this: C:\...\0E:\...\0F:\...\0\0 when i use strcat(), it overwrites the null, so it looks like C:\...E:\...F:\...0\ Is there any easy way to do this? or am i going to have to code a new strcat for myself?

    Read the article

  • Call function based off of a string in Lisp

    - by powerj1984
    I am passing in command line arguments to my Lisp program and they are formatted like this when they hit my main function: ("1 1 1" "dot" "2 2 2") I have a dot function and would like to call it directly from the argument, but this isn't possible because something like (funcall (second args)...) receives "dot" and not dot as the function name. I tried variations of this function: (defun remove-quotes (s) (setf (aref s 0) '"")) to no avail, before realizing that the quotes were not really a part of the string. Is there a simple way to do this, or should I just check each string and then call the appropriate function? Thanks!

    Read the article

  • Java split is eating my characters.

    - by Fenris_uy
    Hi, I have a string like this String str = "la$le\$li$lo". I want to split it to get the following output "la","le\$li","lo". The \$ is a $ escaped so it should be left in the output. But when I do str.split("[^\\\\]\\$") y get "l","le\$l","lo". From what I get my regex is matching a$ and i$ and removing then. Any idea of how to get my characters back? Thanks

    Read the article

  • C++ stringstream reads all zero's

    - by user69514
    I have a file which contains three integers per line. When I read the line I use a stringstream to separate the values, but it only reads the first value as it is. The other two are read as zero's. ifstream inputstream(filename.c_str()); if( inputstream.is_open() ){ string line; stringstream ss; while( getline(inputstream, line) ){ //check line and extract elements int id; double income; int members; ss.clear(); ss.str(line); ss >> id >> income >> members; In the case above, id is extracted correctly, but income, and members get assigned zero instead of the actual value.

    Read the article

  • php string to array and split

    - by RussP
    Hi folks Looking for suggestions as to the best way to do this (I know there are many options): take a variable like this: $args = ('post_type=post&order_by=DESC&limit=10'); the create a function to convert that variable into parts like this: $post_type = post; $order_by = DESC; $limit= 10; Reason is I want a client to be able to use a string like the first to pass variables to a sql query in much the same way (but doesn't have to be exact) as you can do it in WordPress.

    Read the article

< Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >