Search Results

Search found 4616 results on 185 pages for 'c strings'.

Page 135/185 | < Previous Page | 131 132 133 134 135 136 137 138 139 140 141 142  | Next Page >

  • C++ - Efficient way to iterate over the contents of a vector?

    - by Francisco P.
    Hello, everyone! I am implementing a text-based version of Scrabble for a college project. I have a vector containing around 400K strings (my dictionary), and, at some point in every turn, I'm going to have to check if any word in the dictionary can be formed with the pieces in the player's hand. My only solution to this is iterating through the string, one by one, and using a sub-routine I have to check if the string in question can be formed from the player's pieces. I'll implement a quickfail checking if the user has any vowels, but it'll still be woefully inefficient. Any suggestions? Thanks for your time!

    Read the article

  • How to store matrix information in MySQL?

    - by dedalo
    Hi, I'm working on an application that analizes music similarity. In order to do that I proccess audio data and store the results in txt files. For each audio file I create 2 files, 1 containing and 16 values (each value can be like this:2.7000023942731723) and the other file contains 16 rows, each row containing 16 values like the one previously shown. I'd like to store the contents of these 2 file in a table of my MySQL database. My table looks like: Name varchar(100) Author varchar (100) in order to add the content of those 2 file I think I need to use the BLOB data type: file1 blob file2 blob My question is how should I store this info in the data base? I'm working with Java where I have a double array containing the 16 values (for the file1) and a matrix containing the file2 info. Should I process the values as strings and add them to the columns in my database? Thanks

    Read the article

  • Character problem at displaying the result of a query

    - by rahmivolkan
    I am not good at jsp but I wondered what can cause such a problem when every other strings are displayed well: a JSP file queries information of people by their name at Contact (MS Exchange). the query returns the full info of the person; and the first, last names are printed. Last names with apostrophes (Ex: O'reilly) aren't displayed at all. what can be possible solutions? Thanks in advance P.S. I know the way of asking is not suitable but, I need information from people who had such a problem before.

    Read the article

  • PHP PDO - bindValue PARAM_BOOL as string

    - by PHP_guy
    I'm freaking out here and can't figure out what's wrong. I'm pretty new to PDO, but everything works in my code except for booleans which are sent as strings. My code (simplified): $sql = 'SELECT * FROM pages WHERE clean_url_slo = :clean_url_slo AND published = :published LIMIT 1'; $clean_url_slo = 'home'; $published = true; Then I prepare stuff and execute it like this (simplified): $stmt = $db->prepare($sql); $stmt->bindValue(':clean_url_slo',$clean_url_slo,PDO::PARAM_STR); $stmt->bindValue(':published',$published,PDO::PARAM_BOOL); $stmt->execute(); And then here is what comes to mysql (from the mysql log - the query mysql received): 91 Query SELECT * FROM pages WHERE 1=1 AND clean_url_slo='domov' AND published='1' ORDER BY id desc LIMIT 1 As you can see, published is an integer - so always true, which is not OK. Why is that if I'm declaring it as a boolean? using: WAMP SERVER PHP version: 5.3.9 Mysql: 5.5.20 Many thanks for your help..

    Read the article

  • how to construct a long string

    - by david
    I need to construct a long string with javascript. Thats how i tried to do it: var html = '<div style="balbalblaba">&nbsp;</div>'; for(i = 1; i <= 400; i++){ html=+html; }; When i execute that in firefox its taking ages or makes it crash. what is the best way to do that? What is generally the best way to construct big strings in JS. can someone help me?

    Read the article

  • Using the "IN" clause with a comma delimited string from the output of a replace() function in Oracle SQL

    - by Thomas
    Hi All, I have an comma delimited string which I want to use in an "IN" clause of the statement. eg: 100,101,102 Since In and "IN" clause I have to quote the individial strings, I use a replace function: eg: select ''''||replace('100,101,102',',',''', ''')||'''' from dual; The above query works, however, when I try to use the output of the above as an input to the "IN" clause, it returns no data. I am restricted by only SQL statements, so I cannot use PL/SQL code. Kindly help. eg: select * from employee where employee_number in ( select ''''||replace('100,101,102',',',''', ''')||'''' from dual); The above does not work. Please let me know what I am missing.

    Read the article

  • question abouut string sort

    - by davit-datuashvili
    i have question from programming pearls problem is following show how to use lomuto's partitioning scheme to sort varying length bit strings in time proportional to the sum oof their length and algorithm is following each record in x[0..n-1] has an integer length and pointer to the array bit[0..length-1] code void bsort(l,u,depth){ if (l>=u) return; for (int i=l;i<u;i++) if (x[i].length<depth) swap(i,l++); m=l; if (x[i].bit[depth] ==0) swap(i,m++); bsort(l,m-1,depth+1); bsort(m,u,depth+1); please help me i need following things 1. how this algorith works 2.how implement in java?

    Read the article

  • send name="" in jquery javascript?

    - by Azzyh
    Hello So i have this: yes: <input type="radio" value="Y" id="SCvoteY" name="vote"></input> no: <input type="radio" id="SCvoteN" value="N" name="vote"> </input> How do i write that it should transfer name="vote" data ? #vote doesnt work, .vote either (guess it cause thats for class and ID) but what about name then? function DoSCInsert(){ $("#SCres").html("please wait.."); var nocache = '0'; var data = { fID : $("#fID").val(), vote : $("#vote").val(), comment: $("#comment").val(), nocache: nocache }; $.get('insertSC.php', data, onSCInsertComplete); } And how do i shorten this, ive heard that you can you a function in jquery called serialize to pass strings but can you(if you know how) show example by this script how to pass it like this one does?

    Read the article

  • Can a programming language without arrays be turing-complete?

    - by Ring
    My question is simple: There are no arrays possible. That means you can address variables only "statically" by directly using their unique name. (This already throws out the default array syntax variable[ index ] and variable variables) "Emulated arrays" are counted as arrays and excluded too. Examples: You could basically simulate arrays using strings (quite easily actually) or use variable variables as in PHP. Can such a language be turing-complete? Brainf*ck for example has arrays, in fact it is one big array, isn't it?

    Read the article

  • Makefile: expand dependencies

    - by Danyel
    First off, the title is very generic because there are just tons of ways of how to possibly solve this. However, I'm looking for a clean and neat way. Situation: I have two equal object files foo.o and foo-pi.o, the latter of which is position-independent (compiled with -fPIC). Both depend on foo.h and bar.h. Problem: How do I, without code duplication, declare dependency of all foo*.o to bar.h? Solutions so far: $(shell bash -c 'echo -ne foo{-pi,}.o'}: bar.h $(addsuffix .o, $(addprefix fo, o-pi o)): bar.h The first solution is not portable on systems that don't support bash, the second is a dirty solution since I could not figure out how to use empty strings in addprefix.

    Read the article

  • Split string on first two colons

    - by Mark Miller
    I would like to split a column of strings on the first two colons, but not on any subsequent colons: my.data <- read.table(text=' my.string some.data 12:34:56:78 -100 87:65:43:21 -200 a4:b6:c8888 -300 11:bb:ccccc -400 uu:vv:ww:xx -500', header = TRUE) desired.result <- read.table(text=' my.string1 my.string2 my.string3 some.data 12 34 56:78 -100 87 65 43:21 -200 a4 b6 c8888 -300 11 bb ccccc -400 uu vv ww:xx -500', header = TRUE) I have searched extensively and the following question is the closest to my current dilemma: Split on first comma in string Thank you for any suggestions. I prefer to use base R.

    Read the article

  • C# performance of static string[] contains() (slooooow) vs. == operator

    - by Andrew White
    Hiya, Just a quick query: I had a piece of code which compared a string against a long list of values, e.g. if(str == "string1" || str = "string2" || str == "string3" || str = "string4". DoSomething(); And the interest of code clarity and maintainability I changed it to public static string[] strValues = { "String1", "String2", "String3", "String4"}; ... if(strValues.Contains(str) DoSomething(); Only to find the code execution time went from 2.5secs to 6.8secs (executed ca. 200,000 times). I certainly understand a slight performance trade off, but 300%? Anyway I could define the static strings differently to enhance performance? Cheers.

    Read the article

  • How to create simpliest PHP Get API with UTF-8 support?

    - by Ole Jak
    How to create simpliest *(less lines of code, less strange words) PHP Get API *(so any programm made in .Net C# could call url like http://localhost/api.php?astring=your_utf-8_string&bstring=your_utf-8_string ) with UTF-8 support? What I need Is PHP API with one function - concatinate 2 strings so that a simple .net client like this would be able to use it: public string setStream(string astring, string bstring) { string newAstring =Uri.EscapeDataString(astring); string newBstring = Uri.EscapeDataString(bstring); WebClient client = new WebClient(); var result = client.DownloadString(("http://localhost/api.php?" + string.Format("astring={0}&bstring={1}", newAstring, newBstring)).ToString()); return result; }

    Read the article

  • how to generate a random string, and specify the length you want, or better generate unique string on specification you want

    - by HCP
    There is a library to generate Random numbers, so why in't there a library for generation random strings ? In other words how to generate a random string, and specify the length you want, or better generate unique string on specification you want i.e specify the length, a unique string within my application is enough for me. I know I can create a Guid (globally unique identifier) but those are quite long, longer they need to be. int length = 8; string s = RandomString.NextRandomString(length) uniquestringCollection = new UniquestringsCollection(length) string s2 = uniquestringCollection.GetNext();

    Read the article

  • Method sscanf() ambiguous behavior

    - by Carmen Cojocaru
    I am trying to understand how sscanf() works. I ran some examples from this page: http://docs.roxen.com/pike/7.0/tutorial/strings/sscanf.xml and they don't work on my platform. I can't understand why. For instance: "sscanf("4711bar", "%d%s", a, b);" makes the program exit with an error... Here is one of the examples that work: "sscanf("foo", "f%s", a);". Does anybody know why? Do they work on your platforms? Thank you. This is my code: int main(void){ char *b = (char*)malloc(sizeof(char)*100); int a = 0; sscanf("4711bar", "%d%s", a, b); printf("%d", a); printf("%s", b); }

    Read the article

  • Perl Matching ,Extracting , and printing emails

    - by user3448790
    How do I match an email using the The Official Standard: RFC 5322 in a html source code, after that i will extract the strings that are matched ONLY, and print out inly the emails, and not the whole source code? Is there any examples and output to illustrate this? Thnaks! elsif ($_ eq '-dDATA' or $_ eq '-ft') { opendir(DIR,'DATA'); my(@dir) = grep /\.htm/, readdir (DIR); closedir(DIR); my $value = join(@dir); print "$value\n"; foreach my $movies (@dir) { open (my $FHD, "<", "DATA/$movies") || die $!; print <$FHD>; } } }

    Read the article

  • Building a custom iterator.

    - by Isai
    I am making this class which is a custom Map based off a hash map. I have an add method where if you add an object the object will be the key, and its value will be 1 if the object is not currently in the list. However if you add object that is currently in the list its value will be bumped up by 1. So if I added 10 strings which were all the same, the key would be that string and the value will be 10. I understand in practice when I iterate through the map, there is actually only one object to iterate, however, I am trying to create a inner class that will define an iterator that will iterate the same object however many times its value is. I can do this by simply using for loops to construct an appropriate ArrayList and just create an iterator for that, but that is too inefficient. Is there an easy or more efficient way of doing this?

    Read the article

  • C++ - How to efficiently find out if any string in a vector can be assembled from a set of letters

    - by Francisco P.
    Hello, everyone! I am implementing a text-based version of Scrabble for a college project. I have a vector containing around 400K strings (my dictionary), and, at some point in every turn, I'm going to have to check if there's still a word in the dictionary which can be formed with the pieces in the player's hand. I'm checking if the player has any move left... If not, it's game over for the player in question... My only solution to this is iterating through the string, one by one, and using a sub-routine I have to check if the string in question can be formed from the player's pieces. I'll implement a quickfail checking if the user has any vowels, but it'll still be woefully inefficient. Any suggestions? Thanks for your time!

    Read the article

  • Parsing through Arabic / RTL text from left to right

    - by Dan W
    Let's say I have a string in an RTL language such as Arabic with some English chucked in: string s = "Test:?????;?????;?????;a;b" Notice there are semicolons in the string. When I use the Split command like string[] spl = s.Split(';');, then some of the strings are saved in reverse order. This is what happens: ??Test:????? ????? ????? a b The above is out of order compared to the original. Instead, I expect to get this: ?Test: ????? ????? ????? a b I'm prepared to write my own split function. However, the chars in the string also parse in reverse order, so I'm back to square one. I just want to go through each character as it's shown on the screen.

    Read the article

  • C# RichTextBox - Partially setting DetectUrls=false

    - by Suds
    Hi, I have this RichTextBox and I have embedded some http links in it. I have set DetectUrls = true, and it displays the links correctly and handles in the event. In the same RichTextBox, I have one more string displayed which looks like this Type http://< Your host name Now, since DetectUrls= true, the portion "http://<" is displayed as a link, while I want this to be text. If I set the DetectUrls=false just before displaying this string, none of the other links are displayed as links. Is there a way to partially set DetectUrls for some strings and not for others? Thanks

    Read the article

  • Passing a NSString to another ViewController using classes

    - by Jeff Kranenburg
    I know this insanely simple, but I am re-teaching myself the basics and trying to get my head around this:-) I have one ViewController called MainVC and I have one called ClassVC In ClassVC I have this code: @interface ClassVC : UIViewController { NSString *mainLine; } @property (nonatomic, retain) NSString *mainLine; @end and I have this in the implementation file: @synthesize mainLine = _mainLine; -(NSString *)_mainLine { _mainLine = @"This a string from a Class"; return _mainLine; } Now I was thinking that if I #import the ClassVC into MainVC I would be able to transfer that string along as well like so: This code is in the viewDidLoad _mainLabel.text = _secondClass.mainLine; NSLog(@"%@", _secondClass.mainLine); But that is not working - so cannot I not pass strings in through this way???

    Read the article

  • java - check if string ends with certain pattern

    - by The Learner
    I have string like: This.is.a.great.place.too.work. (or) This/is/a/great/place/too/work/ than my java program should give me that the sentence is valid and it has "work". if i Have : This.is.a.great.place.too.work.hahahha (or) This/is/a/great/place/too/work/hahahah Should not give me that there is a work in the sentance. so I am looking at java strings to find a word at the end of the sentance having . (or),(or)/ before it. How can I achieve that

    Read the article

  • How to change word recognition in vim spell?

    - by David
    I like that vim 7.0 supports spell checking via :set spell, and I like that it by default only checks comments and text strings in my C code. But I wanted to find a way to change the behavior so that vim will know that when I write words containing underscores, I don't want that word spell checked. The problem is that I often will refer to variable or function names in my comments, and so right now vim thinks that each piece of text that isn't a complete correct word is a spelling error. Eg. /* The variable proj_abc_ptr is used in function do_func_stuff' */ Most of the time, the pieces seperated by underscores are complete words, but other times they are abbreviations that I would prefer not to add to a word list. Is there any global way to tell vim to include _'s as part of the word when spell checking?

    Read the article

  • Split SQL statements

    - by eaZy
    Hello, I am writing a backend application which needs to be able to send multiple SQL commands to a MySQL server. MySQL = 5.x support multiple statements, but unfortunately we are interfacing with MySQL 4.x. I am trying to find a way (hint: regex) to split SQL statements by their semicolon, but it should ignore semicolons in single and double quotes strings. http://www.dev-explorer.com/articles/multiple-mysql-queries has a very nice regex to do that, but doesn't support double quotes. I'd be happy to hear your suggestions.

    Read the article

< Previous Page | 131 132 133 134 135 136 137 138 139 140 141 142  | Next Page >