Search Results

Search found 35200 results on 1408 pages for 'string'.

Page 21/1408 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • C++ string array binary search

    - by Jose Vega
    string Haystack[] = { "Alabama", "Alaska", "American Samoa", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Guam", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Northern Mariana Islands", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Puerto Rico", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "US Virgin Islands", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"}; string Needle = "Virginia"; if(std::binary_search(Haystack, Haystack+56, Needle)) cout<<"Found"; If I also wanted to find the location of the needle in the string array, is there an "easy" way to find out?

    Read the article

  • How to convert DateTime string into a Format string

    - by AMissico
    With .NET, I have "Thursday, April 10, 2008 1:30:00 PM" and I want "dddd, dd MMMM, yyyy h:m:s t", "6:09:01 PM" and want ""hh:mm:ss tt", "Fri 29 Aug" and want "ddd d MMM", and so on. It seems I should be able to use DateTimeFormatInfo in some way. I figured I can format the date with each pattern returned by GetAllDateTimePatterns, and when the original date string and the formated date string match then I have the format. Yet, I want to generate custom formats, not the standard formats. I want the format string. I do not want the date. I have both the DateTime value and the formatted string value for the date. I need <formatString> as in ToString(<formatString>).

    Read the article

  • need identical string comparison function in php and java

    - by steelbytes
    I have sorted list of strings that I move between php and java. to be able to bsearch on this data, I need the same comparison function. any idea what string compare functions I can use that will always give the same result in both? eg php's strcmp() vs java's String.compareTo() yes I know I could make my own string compare that does char by char carefully, but I was hoping there's a simple answer. PS, don't care if case sensitive or not, as long as it is consistant.

    Read the article

  • std::string == operator not working

    - by Paul
    Hello, I've been using std::string's == operator for years on windows and linux. Now I am compiling one of my libraries on linux, it uses == heavily. On linux the following function fails, because the == returns false even when the strings are equal (case sensitive wise equal) const Data* DataBase::getDataByName( const std::string& name ) const { for ( unsigned int i = 0 ; i < m_dataList.getNum() ; i++ ) { if ( m_dataList.get(i)->getName() == name ) { return m_dataList.get(i); } } return NULL; } The getName() method is declared as follows virtual const std::string& getName() const; I am building with gcc 4.4.1 and libstdc++44-4.4.1. Any ideas? it looks perfectly valid to me. Paul

    Read the article

  • Modify strings in Rails?

    - by Daniel O'Connor
    Hey everyone, So I'm new to Rails (teaching myself as a senior project in high school), and I'm trying to figure out how to modify these strings. Let's say someone writes the following string in a form: "you know you are a geek when" How can I automatically change it to this: "You know you are a geek when..."? I need Rails to check the case of the first letter and check for the three dots then modify the string as necessary. I've looked here, but I can't find anything that would work. Thanks a lot!

    Read the article

  • When getting substring in .Net, does the new string reference the same original string data or does

    - by Elan
    Assuming I have the following strings: string str1 = "Hello World!"; string str2 = str1.SubString(6, 5); // "World" I am hoping that in the above example str2 does not copy "World", but simply ends up being a new string that points to the same memory space only that it starts with an offset of 6 and a length of 5. In actuality I am dealing with some potentially very long strings and am interested in how this works behind the scenes for performance reasons. I am not familiar enaugh with IL to look into this.

    Read the article

  • String of KML needs to be converted to java objects

    - by spartikus
    I have a string of kml coming in on a request object. I have used xjc to create the kml java objects. I am looking for an easy way to create the kml nested java objects from this string. I could parse the string and create each object in the tree by hand but wouldn't it be cool if there was a library or something that would create the java objects for me? Something like KmlType type = parseKML(mykmlStringFromTheRequest); Then type would be a Tree of kml objects. Thanks for the help all.

    Read the article

  • Capture String from Array, C#

    - by Dan Snyder
    I'm trying to figure out how to get a string from an array starting at some given position. Say we have an array that's arbitrarily long and my string starts at location 1000. If I wanted to get a string from a file I would simply use something like getc or scanf or something. How do I carry out these same functions on an array instead of a file? *oh, keep in mind that the array is of type int and is full of numerical representations of ASCII characters.

    Read the article

  • Converting String^ and Collection of String^ to const char*

    - by Jim Jones
    Using VS2008 Managed C++ to wrap a dll. The native method takes a series of single const char* values and a collection of char* values. Going to make an example function: Function1(char * value1, TF_StringList& catList); TF_StringList is a dll class with 3 insert methods, the one I want to use is: TF_StringList::insert(const char* str); So I set up a wrapper method of: WrapperClass::callFunction(String^ mvalue1, ArrayList mcatList); mvalue1 is converted to const char* using: const char* value1 = (char*)(Marshal::StringToHGlobalAnsi(mvalue1)).ToPointer(); However, when a get to the collection of strings, I iterate over it getting each string using the index: String^ mstr = mcatList[i]; Have tried every way of converting String^ to const char* and in every case the TF_StringList::insert(const char* str) method throws a C2663 error which has to do with the const-ness of the value. What is the problem?

    Read the article

  • Marshal managed string[] to unmanaged char**

    - by Vince
    This is my c++ struct (Use Multi-Byte Character Set) typedef struct hookCONFIG { int threadId; HWND destination; const char** gameApps; const char** profilePaths; } HOOKCONFIG; And .Net struct [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct HOOKCONFIG { public int threadId; public IntPtr destination; // MarshalAs? public string[] gameApps; // MarshalAs? public string[] profilePaths; } I got some problem that how do I marshal the string array? When I access the struct variable "profilePaths" in C++ I got an error like this: An unhandled exception of type 'System.AccessViolationException' occurred in App.exe Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. MessageBox(0, cfg.profilePaths[0], "Title", MB_OK); // error ... Orz

    Read the article

  • Help in debugging the string concatenation code

    - by mithun1538
    I have a code to concatenate strings. However, for some reason, the final string is not a combination of the required strings. Consider the following code : //cusEmail is of type String[] String toList = ""; for(i=0; i < cusEmail.length - 1; i++) { toList.concat(cusEmail[i]); toList.concat("; "); System.out.println(cusEmail[i]); } toList.concat(cusEmail[i]); System.out.println(toList); The first sout statement displays the strings in cusEmail[i] correctly. However, once concatenated, the second sout displays a blank / empty. Any reason for this? Am i concatenating it correctly?

    Read the article

  • GetDate in a string in c#

    - by Doncho
    Hi, I'm having some trouble using regular expression to get date in a string. Example : string text = "75000+ Sept.-Oct. 2004"; MatchCollection dates = Regex.Matches(text, @"[0-9]{5,}[+][\s](jan|feb|fev|mar|apr|avr|may|mai|jun|jui|jul|jui|aug|aoû|sept|oct|nov|dec)[\.][\-](jan|feb|fev|mar|apr|avr|may|mai|jun|jui|jul|jui|aug|aoû|sept|oct|nov|dec)[\.]\s[0-9]{4}", RegexOptions.IgnoreCase); This code is matching with my current string but i would like to get in my matchcollection, "Sept 2004" and "Oct 2004" in order to parse it in 2 datetime. If anyone have any idea, thanks a lot.

    Read the article

  • All Permutations of a string when corresponding characters are not in the same place

    - by r20rock
    I need all possible permutations of a given string such that no character should remain at the same place as in the input string. Eg. : for input "ask" Output: all possible permutaions like "ksa", "kas"... such that 'a' is not in the 1st position , 's' is not in the 2nd positions and so on... in any permutation. I only need the count of such possible permutations I can do this by generating all permutations and filtering them but I need a very efficient way of doing this. All characters in the string are "UNIQUE" Preferred language C++.

    Read the article

  • c++ new & delete and string & functions

    - by Newbie
    Okay the previous question was answered clearly, but i found out another problem. What if i do: char *test(int ran){ char *ret = new char[ran]; // process... return ret; } And then run it: for(int i = 0; i < 100000000; i++){ string str = test(rand()%10000000+10000000); // process... // no need to delete str anymore? string destructor does it for me here? } So after converting the char* to string, i dont have to worry about the deleting anymore?

    Read the article

  • Split string into smaller part with constrain [PHP RegEx HTML]

    - by Sadi
    Hello, I need to split long string into a array with following constrains: Each part will have a limited number of character (e.g. not more than 8000 character) Each part can contain multiple sentences (delimited by . [full stop]) but never a partial sentences. Except if the last part of the string (as last part may not have any full stop. The string may contain HTML tags. But the tag can not be divided as ( to ). That means HTML tag should be intact. But starting tag and ending tag can be stay on different segment/chunk. I think regular expression with preg_split can do it. Would please help me with the proper RegEx. Thank you Sadi

    Read the article

  • How to create a formatted localized string?

    - by mystify
    I have a localized string which needs to take a few variables. However, in localization it is important that the order of the variables can change from language to language. So this is not a good idea: NSString *text = NSLocalizedString(@"My birthday is at %@ %@ in %@", nil); In some languages some words come before others, while in others it's reverse. I lack of an good example at the moment. How would I provide NAMED variables in a formatted string? Is there any way to do it without some heavy self-made string replacements? Even some numbered variables like {%@1}, {%@2}, and so on would be sufficient... is there a solution?

    Read the article

  • Java regex replace multiple file paths in a large String

    - by Joe Goble
    So a Regex pro I am not, and I'm looking for a good way to do this. I have a large string which contains a variable number <img> tags. I need to change the path on all of these images to images/. The large string also contains other stuff not just these img's. <img src='http://server.com/stuff1/img1.jpg' /> <img src='http://server.com/stuff2/img2.png' /> Replacing the server name with a ReplaceAll() I could do, it's the variable path in the middle I'm clueless on how to include. It doesn't necessarily need to be a regex, but looping through the entire string just seems wasteful.

    Read the article

  • C++'s std::string pools, debug builds? std::string and valgrind problems

    - by Den.Jekk
    Hello, I have a problem with many valgrind warnings about possible memory leaks in std::string, like this one: 120 bytes in 4 blocks are possibly lost in loss record 4,192 of 4,687 at 0x4A06819: operator new(unsigned long) (vg_replace_malloc.c:230) by 0x383B89B8B0: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.8) by 0x383B89C3B4: (within /usr/lib64/libstdc++.so.6.0.8) by 0x383B89C4A9: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.8) I'm wondering: does std::string (GCC 4.1.2) use any memory pools? if so, is there any way to disable the pools (in form of a debug build etc.)? Regards, Den

    Read the article

  • converting string to int in C++

    - by xbonez
    I am trying to convert a string I read in from a file to an int value so I can store it in an integer variable. This is what my code looks like: ifstream sin; sin.open("movie_output.txt"); string line; getline(sin,line); myMovie.setYear(atoi(line)); Over here, setYear is a mutator in the Movie class (myMovie is an object of Movie class) that looks like this: void Movie::setYear(unsigned int year) { year_ = year; } When I run the code, I get the following error: error C2664: 'atoi' : cannot convert parameter 1 from 'std::string' to 'const char *' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

    Read the article

  • C++ Stringstream int to string but returns null

    - by jumm
    Hi below is my function: string Employee::get_print(void) { string out_string; stringstream ss; ss << e_id << " " << type << endl; out_string = ss.str(); return out_string; } e_id and type are int and they contain values from the class Employee. But when I pass them into the stringstream they just clear the string when I try to out put it. But if I don't have a int in the ss << "Some text" << endl; this output fine. What am I doing wrong =S

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >