Search Results

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

Page 116/1413 | < Previous Page | 112 113 114 115 116 117 118 119 120 121 122 123  | Next Page >

  • Including huge string in our c++ programs ?

    - by Xinus
    I am trying to include huge string in my c++ programs, Its size is 20598617 characters , I am using #define to achieve it. I have a header file which contains this statement #define "<huge string containing 20598617 characterd>" When I try to compile the program I get error as fatal error C1060: compiler is out of heap space I tried following command line options with no success /Zm200 /Zm1000 /Zm2000 How can I make successful compilation of this program? Platform: Windows 7

    Read the article

  • Limited-length string class

    - by wood_brian
    Is there a limited-length string class around? I've searched a little on the net and didn't find anything. I'm interested in a class that limits (possibly at compile time) the length to 255, so marshalling the string's length only requires one byte.

    Read the article

  • occurance of string

    - by David
    i know you can find the first and last occurrence in a string using strstr() and strchr but how do i find the second occurrence, and the third occurrence of needle inside haystack? im using this to find the last occurrence of needle and the first occurrence of another needle and their position, then return the string that is in between each. thank you.

    Read the article

  • how to search a string in structure variable ( C# )

    - by deep
    public struct Items { public string Id; public string Name; } public Items[] _items = null; if (_items.Contains("Table")) { // i need to check the structure and need to return correponding id } and am having a list of variables in my structure variable... i need to search a Name in the structure(_items) and i want to return the Corresponding Id. how to do this,

    Read the article

  • Return an empty C-String

    - by Evorlor
    Simple Question: How do you return an empty C-String with as little code as possible? I have code that needs to return an empty char*. I am looking for something along the lines of return "";. I know there are several ways to do this, but I am looking for the most efficient way possible. Using return ""; gives warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings] Thanks!

    Read the article

  • Should the 12-String be in it's own class and why?

    - by MayNotBe
    This question is regarding a homework project in my first Java programming class (online program). The assignment is to create a "stringed instrument" class using (among other things) an array of String names representing instrument string names ("A", "E", etc). The idea for the 12-string is beyond the scope of the assignment (it doesn't have to be included at all) but now that I've thought of it, I want to figure out how to make it work. Part of me feels like the 12-String should have it's own class, but another part of me feels that it should be in the guitar class because it's a guitar. I suppose this will become clear as I progress but I thought I would see what kind of response I get here. Also, why would they ask for a String[] for the instrument string names? Seems like a char[] makes more sense. Thank you for any insight. Here's my code so far (it's a work in progress): public class Guitar { private int numberOfStrings = 6; private static int numberOfGuitars = 0; private String[] stringNotes = {"E", "A", "D", "G", "B", "A"}; private boolean tuned = false; private boolean playing = false; public Guitar(){ numberOfGuitars++; } public Guitar(boolean twelveString){ if(twelveString){ stringNotes[0] = "E, E"; stringNotes[1] = "A, A"; stringNotes[2] = "D, D"; stringNotes[3] = "G, G"; stringNotes[4] = "B, B"; stringNotes[5] = "E, E"; numberOfStrings = 12; } } public int getNumberOfStrings() { return numberOfStrings; } public void setNumberOfStrings(int strings) { if(strings == 12 || strings == 6) { if(strings == 12){ stringNotes[0] = "E, E"; stringNotes[1] = "A, A"; stringNotes[2] = "D, D"; stringNotes[3] = "G, G"; stringNotes[4] = "B, B"; stringNotes[5] = "E, E"; numberOfStrings = strings; } if(strings == 6) numberOfStrings = strings; }//if else System.out.println("***ERROR***Guitar can only have 6 or 12 strings***ERROR***"); } public void getStringNotes() { for(int i = 0; i < stringNotes.length; i++){ if(i == stringNotes.length - 1) System.out.println(stringNotes[i]); else System.out.print(stringNotes[i] + ", "); }//for }

    Read the article

  • Should the 12-String be in it's own class and why? Java

    - by MayNotBe
    This is my first question here. I will amend it as instructed. This is regarding a homework project in my first Java programming class (online program). The assignment is to create a "stringed instrument" class using (among other things) an array of String names representing instrument string names ("A", "E", etc). The idea for the 12-string is beyond the scope of the assignment (it doesn't have to be included at all) but now that I've thought of it, I want to figure out how to make it work. Part of me feels like the 12-String should have it's own class, but another part of me feels that it should be in the guitar class because it's a guitar. I suppose this will become clear as I progress but I thought I would see what kind of response I get here. Also, why would they ask for a String[] for the instrument string names? Seems like a char[] makes more sense. Thank you for any insight. Here's my code so far (it's a work in progress): public class Guitar { private int numberOfStrings = 6; private static int numberOfGuitars = 0; private String[] stringNotes = {"E", "A", "D", "G", "B", "A"}; private boolean tuned = false; private boolean playing = false; public Guitar(){ numberOfGuitars++; } public Guitar(boolean twelveString){ if(twelveString){ stringNotes[0] = "E, E"; stringNotes[1] = "A, A"; stringNotes[2] = "D, D"; stringNotes[3] = "G, G"; stringNotes[4] = "B, B"; stringNotes[5] = "E, E"; numberOfStrings = 12; } } public int getNumberOfStrings() { return numberOfStrings; } public void setNumberOfStrings(int strings) { if(strings == 12 || strings == 6) { if(strings == 12){ stringNotes[0] = "E, E"; stringNotes[1] = "A, A"; stringNotes[2] = "D, D"; stringNotes[3] = "G, G"; stringNotes[4] = "B, B"; stringNotes[5] = "E, E"; numberOfStrings = strings; } if(strings == 6) numberOfStrings = strings; }//if else System.out.println("***ERROR***Guitar can only have 6 or 12 strings***ERROR***"); } public void getStringNotes() { for(int i = 0; i < stringNotes.length; i++){ if(i == stringNotes.length - 1) System.out.println(stringNotes[i]); else System.out.print(stringNotes[i] + ", "); }//for }

    Read the article

  • T-SQL While Loop and concatenation

    - by JustinT
    I have a SQL query that is supposed to pull out a record and concat each to a string, then output that string. The important part of the query is below. DECLARE @counter int; SET @counter = 1; DECLARE @tempID varchar(50); SET @tempID = ''; DECLARE @tempCat varchar(255); SET @tempCat = ''; DECLARE @tempCatString varchar(5000); SET @tempCatString = ''; WHILE @counter <= @tempCount BEGIN SET @tempID = ( SELECT [Val] FROM #vals WHERE [ID] = @counter); SET @tempCat = (SELECT [Description] FROM [Categories] WHERE [ID] = @tempID); print @tempCat; SET @tempCatString = @tempCatString + '<br/>' + @tempCat; SET @counter = @counter + 1; END When the script runs, @tempCatString outputs as null while @tempCat always outputs correctly. Is there some reason that concatenation won't work inside a While loop? That seems wrong, since incrementing @counter works perfectly. So is there something else I'm missing?

    Read the article

  • Perl strings internals

    - by n0rd
    How does perl strings represented internally? What encoding is used? How do I handle different encodings properly? I've been using perl for quite a long time, but it didn't include a lot of string handling in different encodings, and when I encountered a minor problem that had something to do with encodings I usually resorted to some shamanic actions. Until this moment I thought about perl strings as sequences of bytes, which did fit pretty well for my tasks. Now I need to do some processing of UTF-8 encoded file and here starts trouble. First, I read file into string like this: open(my $in, '<', $ARGV[0]) or die "cannot open file $ARGV[0] for reading"; binmode($in, ':utf8'); my $contents; { local $/; $contents = <$in>; } close($in); then simply print it: print $contents; And I get two things: a warning Wide character in print at <scriptname> line <n> and a garbage in console. So I can conclude that perl strings have a concept of "character" that can be "wide" or not, but when printed these "wide" characters are represented in console as multiple bytes, not as single "character". (I wonder now why did all my previous experience with binary files worked quite how I expected it to work without any "character" issues). Why then I see garbage in console? If perl stores strings as character in some known encoding, I don't think there is a big problem to find out console encoding and print text properly. (I use Windows, BTW). If perl stores strings as multibyte sequences (e.g. using same UTF-8 encoding), why is it done this way? From my C experience handling multibyte strings is PAIN.

    Read the article

  • Getting text between quotes using regular expression

    - by Camsoft
    I'm having some issues with a regular expression I'm creating. I need a regex to match against the following examples and then sub match on the first quoted string: Input strings ("Lorem ipsum dolor sit amet, consectetur adipiscing elit.") ('Lorem ipsum dolor sit amet, consectetur adipiscing elit. ') ('Lorem ipsum dolor sit amet, consectetur adipiscing elit. ', 'arg1', "arg2") Must sub match Lorem ipsum dolor sit amet, consectetur adipiscing elit. Regex so far: \((["'])([^"']+)\1,?.*\) The regex does a sub match on the text between the first set of quotes and returns the sub match displayed above. This is almost working perfectly, but the problem I have is that if the quoted string contains quotes in the text the sub match stops at the first instance, see below: Failing input strings ("Lorem ipsum dolor \"sit\" amet, consectetur adipiscing elit.") Only sub matches: Lorem ipsum dolor ("Lorem ipsum dolor 'sit' amet, consectetur adipiscing elit.") The entire match fails. Notes The input strings are actually php code function calls. I'm writing a script that will scan .php source files for a specific function and grab the text from the first parameter.

    Read the article

  • Using Regex, how can I remove certain characters from inside angle-brackets, leaving the characters

    - by Iain Fraser
    Edit: To be clear, please understand that I am not using Regex to parse the html, that's crazy talk! I'm simply wanting to clean up a messy string of html so it will parse Edit #2: I should also point out that the control character I'm using is a special unicode character - it's not something that would ever be used in a proper tag under any normal circumstances Suppose I have a string of html that contains a bunch of control characters and I want to remove the control characters from inside tags only, leaving the characters outside the tags alone. For example Here the control character is the numeral "1". Input The quick 1<strong>orange</strong> lemming <sp11a1n 1class1='jumpe111r'11>jumps over</span> 1the idle 1frog Desired Output The quick 1<strong>orange</strong> lemming <span class='jumper'>jumps over</span> 1the idle 1frog So far I can match tags which contain the control character but I can't remove them in one regex. I guess I could perform another regex on my matches, but I'd really like to know if there's a better way. My regex Bear in mind this one only matches tags which contain the control character. <(([^>])*?`([^>])*?)*?> Thanks very much for your time and consideration. Iain Fraser

    Read the article

  • compact Number formatting behavior in Java (automatically switch between decimal and scientific notation)

    - by kostmo
    I am looking for a way to format a floating point number dynamically in either standard decimal format or scientific notation, depending on the value of the number. For moderate magnitudes, the number should be formatted as a decimal with trailing zeros suppressed. If the floating point number is equal to an integral value, the decimal point should also be suppressed. For extreme magnitudes (very small or very large), the number should be expressed in scientific notation. Alternately stated, if the number of characters in the expression as standard decimal notation exceeds a certain threshold, switch to scientific notation. I should have control over the maximum number of digits of precision, but I don't want trailing zeros appended to express the minimum precision; all trailing zeros should be suppressed. Basically, it should optimize for compactness and readability. 2.80000 - 2.8 765.000000 - 765 0.0073943162953 - 0.00739432 (limit digits of precision—to 6 in this case) 0.0000073943162953 - 7.39432E-6 (switch to scientific notation if the magnitude is small enough—less than 1E-5 in this case) 7394316295300000 - 7.39432E+6 (switch to scientific notation if the magnitude is large enough—for example, when greater than 1E+10) 0.0000073900000000 - 7.39E-6 (strip trailing zeros from significand in scientific notation) 0.000007299998344 - 7.3E-6 (rounding from the 6-digit precision limit causes this number to have trailing zeros which are stripped) Here's what I've found so far: The .toString() method of the Number class does most of what I want, except it doesn't upconvert to integer representation when possible, and it will not express large integral magnitudes in scientific notation. Also, I'm not sure how to adjust the precision. The "%G" format string to the String.format(...) function allows me to express numbers in scientific notation with adjustable precision, but does not strip trailing zeros. I'm wondering if there's already some library function out there that meets these criteria. I guess the only stumbling block for writing this myself is having to strip the trailing zeros from the significand in scientific notation produced by %G.

    Read the article

  • How can I remove certain characters from inside angle-brackets, leaving the characters outside alone

    - by Iain Fraser
    Edit: To be clear, please understand that I am not using Regex to parse the html, that's crazy talk! I'm simply wanting to clean up a messy string of html so it will parse Edit #2: I should also point out that the control character I'm using is a special unicode character - it's not something that would ever be used in a proper tag under any normal circumstances Suppose I have a string of html that contains a bunch of control characters and I want to remove the control characters from inside tags only, leaving the characters outside the tags alone. For example Here the control character is the numeral "1". Input The quick 1<strong>orange</strong> lemming <sp11a1n 1class1='jumpe111r'11>jumps over</span> 1the idle 1frog Desired Output The quick 1<strong>orange</strong> lemming <span class='jumper'>jumps over</span> 1the idle 1frog So far I can match tags which contain the control character but I can't remove them in one regex. I guess I could perform another regex on my matches, but I'd really like to know if there's a better way. My regex Bear in mind this one only matches tags which contain the control character. <(([^>])*?`([^>])*?)*?> Thanks very much for your time and consideration. Iain Fraser

    Read the article

  • Non-latin-characters ordering in database with "order by"

    - by nybon
    I just found some strange behavior of database's "order by" clause. In string comparison, I expected some characters such as '[' and '_' are greater than latin characters such as 'i' considering their orders in the ASCII table. However, the sorting results from database's "order by" clause is different with my expectation. Here's my test: SQLite version 3.6.23 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table products(name varchar(10)); sqlite> insert into products values('ipod'); sqlite> insert into products values('iphone'); sqlite> insert into products values('[apple]'); sqlite> insert into products values('_ipad'); sqlite> select * from products order by name asc; [apple] _ipad iphone ipod This behavior is different from Java's string comparison (which cost me some time to find this issue). I can verify this in both SQLite 3.6.23 and Microsoft SQL Server 2005. I did some web search but cannot find any related documentation. Could someone shed me some light on it? Is it a SQL standard? Where can I find some information about this? Thanks in advance.

    Read the article

  • C++ cin whitespace question

    - by buddyfox
    Programming novice here. I'm trying to allow a user to enter their name, firstName middleName lastName on one line in the console (ex. "John Jane Doe"). I want to make the middleName optional. So if the user enters "John Doe" it only saves the first and last name strings. If the user enters "John Jane Doe" it will save all three. I was going to use this: cin >> firstName >> middleName >> lastName; then I realized that if the user chooses to omit their middle name and enters "John Doe" the console will just wait for the user to enter a third string... I know I could accomplish this with one large string and breaking it up into two or three, but isn't there a simpler way to do it with three strings like above? I feel like I'm missing something simple here... Thanks in advance.

    Read the article

  • .each or search function, how can I make use of those?

    - by Noor
    I have a ul list, with 10 items, and I have a label that displays the selected li text. When I click a button, I need to check the label, versus all the list items to find the matching one, when it finds that I need to assign the corresponding number. I.e. list: Messi Cristiano Zlatan hidden values of list items: www.messi.com www.cronaldo.com www.ibra.com label: Zlatan script (thought)procces: get label text, search list for matching string, get the value of that string. (and if someone could point me in a direction to learn these basic(?) stuff. tried to be as specific as possible, thanks guys! edit: really sorry for not being clear. the li's are all getting a class dynamically (.listitem). the links can be stored in an array or in a hidden field (or other ul thats hidden) it doesn't really matter where the links are.. $('.listitem').click(function() { $("#elname").text($(this).text()); $("#such").attr("href", $(this).attr('value')); }); I was trying that with the li's having values but I realized that li's can't have values.. thanks again!

    Read the article

  • Data Structures for Junior Java Developer

    - by user1639637
    Ok,still learning Arrays. I wrote this code which fills the array named "rand" with random numbers between 0 and 1( exclusive). I want to start learning Complexity. the For loop executes n times (100 times) ,every time it takes O(1) time,so the worse case scenario is O(n),am I right? Also,I used ArrayList to store the 100 elements and I imported "Collections" and used Collections.sort() method to sort the elements. import java.util.Arrays; public class random { public static void main(String args[]) { double[] rand=new double[10]; for(int i=0;i<rand.length;i++) { rand[i]=(double) Math.random(); System.out.println(rand[i]); } Arrays.sort(rand); System.out.println(Arrays.toString(rand)); } } ArrayList: import java.util.ArrayList; import java.util.Collections; public class random { public static void main(String args[]) { ArrayList<Double> MyArrayList=new ArrayList<Double>(); for(int i=0;i<100;i++) { MyArrayList.add(Math.random()); } Collections.sort(MyArrayList); for(int j=0;j<MyArrayList.size();j++) { System.out.println(MyArrayList.get(j)); } } }

    Read the article

  • How to deal with Unicode strings in C/C++ in a cross-platform friendly way?

    - by Sorin Sbarnea
    On platforms different than Windows you could easily use char * strings and treat them as UTF-8. The problem is that on Windows you are required to accept and send messages using wchar* strings (W). If you'll use the ANSI functions (A) you will not support Unicode. So if you want to write truly portable application you need to compile it as Unicode on Windows. Now, In order to keep the code clean I would like to see what is the recommended way of dealing with strings, a way that minimize ugliness in the code. Type of strings you may need: std::string, std::wstring, std::tstring,char *,wchat_t *, TCHAR*, CString (ATL one). Issues you may encounter: cout/cerr/cin and their Unicode variants wcout,wcerr,wcin all renamed wide string functions and their TCHAR macros - like strcmp, wcscmp and _tcscmp. constant strings inside code, with TCHAR you will have to fill your code with _T() macros. What approach do you see as being best? (examples are welcome) Personally I would go for a std::tstring approach but I would like to see how would do to the conversions where they are necessary.

    Read the article

< Previous Page | 112 113 114 115 116 117 118 119 120 121 122 123  | Next Page >