Search Results

Search found 35302 results on 1413 pages for 'string literals'.

Page 173/1413 | < Previous Page | 169 170 171 172 173 174 175 176 177 178 179 180  | Next Page >

  • C++ argv path specifier

    - by sub
    In the interpreter for my programming languages I have to correctly handle the parts in case the import function is called. I then need to check if such a file is in the /libs folder (located at the same place as my executeable!) and if it doesn't exist I have to check in the directory of the current script. How can I get the exact path to the directory where the executeable is located from argv? What is the best way to remove the file from the end of a path, e.g: C:/a/b/c/file.exe should become C:/a/b/c/

    Read the article

  • How to get number of bytes read from QTextStream

    - by user261882
    The following code I am using to find the number of read bytes from QFile. With some files it gives the correct file size, but with some files it gives me a value that is approximatively fileCSV.size()/2. I am sending two files that have same number of characters in it, but have different file sizes link text. Should i use some other objects for reading the QFile? QFile fileCSV("someFile.txt"); if ( !fileCSV.open(QIODevice::ReadOnly | QIODevice::Text)) emit errorOccurredReadingCSV(this); QTextStream textStreamCSV( &fileCSV ); // use a text stream int fileCSVSize = fileCSV.size()); qint64 reconstructedCSVFileSize = 0; while ( !textStreamCSV.atEnd() ) { QString line = textStreamCSV.readLine(); // line of text excluding '\n' if (!line.isEmpty()) { reconstructedCSVFileSize += line.size(); //this doesn't work always reconstructedCSVFileSize += 2; } else reconstructedCSVFileSize += 2; } I know that reading the size of QString is wrong, give me some other solutions if you can. Thank you.

    Read the article

  • MySQL - Where - search string - MATCH.

    - by Jamie
    Hi guys, Quick question. I'm in a bit of a rush but if someone could quickly point me in the right direction I would be very very happy. I have a field in the db, let's call it field_a which returns a string in the format "20,50,60,80" etc. I wish to do a query which will search in this field to see if 20 exists. Could I use MySQL MATCH or is there a better way? Thank you!

    Read the article

  • Alligator tags(<% %>) inside js string?

    - by bangoker
    I am trying to redirect a page reading the url from the config file. However, when I try this: <script type="text/javascript"> <%string redirectUrl = System.Web.Configuration.WebConfigurationManager.AppSettings["RedirectURL"];%> window.parent.location.replace("<%=redirectUrl%>"); </script> the alligator tags <% % are Not being highlighted, and when I run I get the following error in the yellow screen: the controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). What am I doing wrong?? Thanks!

    Read the article

  • How do I create English-language list (name1, name2, AND name3) in Ruby on Rails?

    - by Angela
    Quite possibly there could be a rails magic I've missed, but I'm guessing it will be in Ruby. I have a model called Company which has_many Contacts. Suppose Company has Contact 1, Contact 2, Contact 3, and Contact 4. When I create a textblog for each Contact, I want to output the following (where Contact = Contact 1) "Hi, Contact 1, I am also writing to Contact 2, Contact 3, and Contact 4." So it needs to extract the Contact in the salutation and then list them, inserting "and" before the last Contact in the list.

    Read the article

  • .NET: efficient way to produce a string from a Dictionary<K,V> ?

    - by Cheeso
    Suppose I have a Dictionary<String,String>, and I want to produce a string representation of it. The "stone tools" way of doing it would be: private static string DictionaryToString(Dictionary<String,String> hash) { var list = new List<String> (); foreach (var kvp in hash) { list.Add(kvp.Key + ":" + kvp.Value); } var result = String.Join(", ", list.ToArray()); return result; } Is there an efficient way to do this in C# using existing extension methods? I know about the ConvertAll() and ForEach() methods on List, that can be used to eliminate foreach loops. Is there a similar method I can use on Dictionary to iterate through the items and accomplish what I want?

    Read the article

  • Escaping quotes twice in PHP

    - by Genadinik
    Hello, I have a complicated form where I first have to take some _GET parameters and obviously I have to do a mysql_real_escape_string() on them since I look stuff up in the database with them. Them problem for me is after the initial db lookup. When the user submits a form, I send them along as a _POST request and obviously have to do this mysql_real_escape_string call again just in case someone tries to hack my site with a faked form submission. Then the problem I have is the arguments are escaped twice and my queries begin to look strange like this: select field1 , field2 , from my_table where some_id = \'.$lookup_id.\' ... So the system seems to be adding \' and it is messing me up :) Also, in my other forms I have not seen such behavior. Any ideas on what may be causing this? One weird thing is that I tried to send unescaped parameters to the post, and the same problem happens. That is a clue, but not a sufficient one for me. :( Thanks, Alex

    Read the article

  • What is the meaning of this C++ Error std::length_error

    - by Janusz
    While running my program I get this Error: terminate called after throwing an instance of 'std::length_error' what(): basic_string::_S_create Abort trap I know that you can't do much without the code but I think that error is to deep in the code to copy all of it. Maybe I can figure it out if I understand what this error means. Is this a sign for an issue with reading or writing at the wrong memory address? Is there something I can do to get more information about the problem from my program?

    Read the article

  • In silverlight how do you scrub a string

    - by jvcoach23
    I have a string that looks like this " Into" and I can't figure out what the " " value is just before the Into. It's not a space, it's not an enter. At least i don't think so. I've tried doing a replace to get rid of it.. So now i'm just trying to figure out what that character value is. Convert.int32 doesn't get it done... What can i use to get rid of that character... I guess i could write a function that would loop through the alphabet and do it that way.. but figured there was a better way. thanks shannon

    Read the article

  • Better way to read last portion of URL

    - by enloz
    This script should detect the last portion in the full path, and if it is stackoverflow output ok $current_url = $_SERVER['REQUEST_URI']; $current_url_arr = explode('/',$current_url); $count = count($current_url_arr); if($current_url_arr[$count-2] == 'stackoverflow'){ echo 'ok'; } else { echo 'not ok'; } Example 1: www.myserver.ext/something/else/stackoverflow/ Output: ok Example 2: www.myserver.ext/something/else/stackoverflow Output: not ok Example 3: www.myserver.ext/something/else/stackoverflow/foo Output: not ok I hope that you understand the idea. This script works fine, but I'm wondering if there is any better, elegant way to read last portion of URL?

    Read the article

  • Problem storing string containing quotes

    - by Jack
    I have the following table - $sql = "CREATE TABLE received_queries ( sender_screen_name varchar(50), text varchar(150) )"; I use the following SQL statement to store values in the table $sql = "INSERT INTO received_queries VALUES ('$sender_screen_name', '$text')"; Now I am trying to store the following string as 'text'. One more #haiku: Cotton wool in mind; feeling like a sleep won't cure; I need some coffee. and I get the following error message Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't cure; I need some coffee.')' at line 1 I think must be a pretty common problem. How do I solve it?

    Read the article

  • java decmail string to AS 3.0 conversion procedure

    - by Jack Smith
    Hello, I have a problem with conversion java code to action script 3. Anyone can help with code translation? Thanks. public static short[] decmail_str_to_binary_data(String s) { short[] data = new short[s.length()/2]; for (int i = 0; i < s.length(); i += 2) { char c1 = s.charAt(i); char c2 = s.charAt(i + 1); int comb = Character.digit(c1, 16) & 0xff; comb <<= 4; comb += Character.digit(c2, 16) & 0xff; data[i/2] = (short)comb; } return data; }

    Read the article

  • Regex - Trim character at the end of a string

    - by Torez
    I am trying to remove a trailing - (dash) at the end of the string. Here is my code: <?php $str = 'SAVE $45! - Wed. Beach Co-ed 6s (Jul-Aug)'; echo ereg_replace('([^a-z0-9]+)','-',strtolower($str)); ?> produces this: save-45-wed-beach-co-ed-6s-jul-aug- How can I remove a specific trailing character only if its there, in this case the dash? Thanks in advance.

    Read the article

  • Why do spaces appear in my string?

    - by Abs
    Hello all, I have this function below which returns all IDs of checked boxes on my page seperated by a comma. It works great but the problem is, it seems to put a lot of white space after each checkbox ID. I can't seem to figure out why? /*Returns selected checkbox ID in string seperated by comma */ function get_selected_chkbox(){ var checked_string = ''; $('#report_table').find("input[type='checkbox']").each(function(){ if(this.checked){ checked_string = checked_string + this.id + ','; } }); alert(checked_string);//test1 ,test2 , return checked_string; } Thanks all for any help

    Read the article

  • How to read input until the user enters ^X

    - by Koning Baard
    I am creating an interpreter for my esolang, and I need the user to enter some text which then will be interpreted as an INTERCAL program. I want the user to enter text, which may contain any character including newlines, until the user presses ^X (Ctrl-X), like this: Enter your code followed by ^X: Bla Blablabla Bla^X Thank you for entering your code (line 2, 3 and 4 were entered by the user) can anyone explain me how I can read input including newlines till the user enters ^X? Thanks

    Read the article

  • Rendering Views as String with Spring MVC and Apache Tiles

    - by lynxforest
    I am trying to reuse some of my tiles in a controller which is returning a json response to the client. I would like to return a json response similar to the following format: { 'success': <true or false>, 'response': <the contents of an apache tile> } In my controller I would like to perform logic similar to this pseudocode: boolean valid = validator.validate(modelObj) String response = "" if(valid){ response = successView.render() // im looking for a way to actually accomplish // this, where the successView is the apache tiles view. // I would also need to pass a model map to the view somehow. }else{ response = errorView.render() } writeJsonResponse(httpResponse, /* a Map whose json representation looks like the one I described above. */)

    Read the article

  • Android string formatiing from xml

    - by mann
    I am parsing xml from server. One of its node contains data like <distance>16.3432434324354324km</distance> I am putting it into hashmap like for (int i = 0; i < nl.getLength(); i++) { map.put(KEY_DISTANCE, parser.getValue(e, KEY_DISTANCE)); // adding HashList to ArrayList menuItems.add(map); } Everything is nice. But i want it two decimal places for example i want its value should be 16.34km rather then 16.343234324342342km I tried with DecimalFormat twoDForm=new DecimalFormat("##.00"); try{ Double StartVTwo=Double.valueOf(KEY_DISTANCE); Double resultDouble1 = Double.valueOf(twoDForm.format(StartVTwo)); Log.e("check", String.valueOf(resultDouble1)); }catch (NumberFormatException e){ Log.e("error"," This is error "); } But it shows exception and prints this message. Any help would be appreciated!!

    Read the article

  • how to write regular expression to validate a string using regex in C#

    - by Charu
    I need to validate a user input based on condition. i wrote a regular expression to do so, but it's failing not sure why. Can somebody point where i am making mistake? Regex AccuracyCodeHexRegex = new Regex(@"^[PTQA]((0|8)[01234567]){2}$"); This is what i am trying to validate(If the string is a subset of these strings then it is valid): Phh, Thh, Qhh, Ahh where 'h' is a hex digit in the set {00, 80, 01, 81, 02, 82, 03, 83, 04, 84, 05, 85, 06, 86, 07, 87} Ex: P00 is valid P20 is not valid

    Read the article

  • Sort Strings by first letter [C]

    - by Blackbinary
    I have a program which places structures in a linked list based on the 'name' they have stored in them. To find their place in the list, i need to figure out if the name im inserting is earlier or later in the alphabet then those in the structures beside it. The names are inside the structures, which i have access to. I don't need a full comaparison if that is more work, even just the first letter is fine. Thanks for the help!

    Read the article

< Previous Page | 169 170 171 172 173 174 175 176 177 178 179 180  | Next Page >