I'm writing a program in Java. They say to not use String functions - so how can I get characters in a String using the index but not using charAt()?   other question has answer but they all are using charAt()  I also want to get characters one by one using a loop.
73501
StringTokenizer? Convert the String to a char[] and iterate over that? Something else?
63138
I have a string that I would like to tokenize. But the C strtok() function requires my string to be a char*. How can I do this simply?  I tried:  token = strtok(str.c_str(), " ");    which fails because it turns it into a const char*, not a char*
111654
I just . Namely, the C++ function:  void returnCharPtr(char * someString, int n);   cannot return any CharPtr because the someString pointer is passed by value. Also, the intent of the author was clear:      So, another option is to pass the parameter as an argument, so you process your string in a function but don't create a new copy.   But as the change was rejected (3 vs 2) the post stayed in an incorrect state (IMHO).   I left a comment to the author. Can I argue with the editors' decision?
102259
I need to search a string in the string array. I dont want to use any for looping in it  string [] arr = {"One","Two","Three"};  string theString = "One"   I need to check whether theString variable is present in arr.
15391
What's the C++ way of parsing a string (given as char *) into an int? Robust and clear error handling is a plus (instead of ).
5654
What is the difference between using  on the array element as opposed to using ?   For example:  myArray = ['a', 'b', 'c', 'd'];  delete myArray[1]; //  or myArray.splice (1, 1);   Why even have the splice method if I can delete array elements like I can with objects?
9572
Is there a performance hit if we use a loop instead of recursion or vice versa in algorithms where both can serve the same purpose? Eg: Check if the given string is a palindrome. I have seen many programmers using recursion as a means to show off when a simple iteration algorithm can fit the bill. Does the compiler play a vital role in deciding what to use?
71900
In languages like Java and C#, strings are immutable and it can be computationally expensive to build a string one character at a time.  In said languages, there are library classes to reduce this cost such as C# System.Text.StringBuilder and Java java.lang.StringBuilder.  Does php (4 or 5; I'm interested in both) share this limitation?  If so, are there similar solutions to the problem available?
9051
Check out the below program.   try {     for (String data : Files.readAllLines(Paths.get("D:/sample.txt"))){         String[] de = data.split(";");         System.out.println("Length = " + de.length);     } } catch (IOException e) {     e.printStackTrace(); }   Sample.txt:   1;2;3;4 A;B;; a;b;c;   Output:   Length = 4 Length = 2 Length = 3   Why second and third output is giving 2 and 3 instead of 4. In sample.txt file, condition  for 2nd and 3rd line is should give newline(\n or enter) immediately after giving delimiter for the third field. Can anyone help me how to get length as 4 for 2nd and 3rd line without changing the condition of the sample.txt file and how to print the values of de[2] (throws  ArrayIndexOutOfBoundsException)?
6287
I'm doing simple string input parsing and I am in need of a string tokenizer. I am new to C# but have programmed Java, and it seems natural that C# should have a string tokenizer. Does it? Where is it? How do I use it?
77935
How do you split a string?  Lets say i have a string "dog, cat, mouse,bird"  My actual goal is to insert each of those animals into a listBox, so they would become items in a list box.  but i think i get the idea on how to insert those items if i know how to split the string. or does anyone know a better way to do this?  im using asp c#
82090
int i = 4; string text = "Player "; cout &lt;&lt; (text + i);   I'd like it to print Player 4.  The above is obviously wrong but it shows what I'm trying to do here. Is there an easy way to do this or do I have to start adding new includes?
17958
I'd like to use JavaScript to calculate the width of a string. Is this possible without having to use a monospace typeface?  If it's not built-in, my only idea is to create a table of widths for each character, but this is pretty unreasonable especially supporting  and different type sizes (and all browsers for that matter).
13955
Unless I am missing an obvious built-in method, what is the quickest way to get the nth occurrence of a string within a string?  I realize that I could loop the  method by updating its start index on each iteration of the loop. But doing it this way seems wasteful to me.
87194
I've been told that code such as:  for (int i = 0; i &lt; x.length(); i++) {     // blah }   is actually O(n^2) because of the repeated calls to x.length(). Instead I should use:  int l = x.length(); for (int i = 0; i &lt; l; i++) {     // blah }   Is this true? Is string length stored as a private integer attribute of the String class? Or does String.length() really walk the whole string just to determine its length?
114309
How to calculate the length (in pixels) of a string in Java?  Preferable without using Swing.  EDIT: I would like to draw the string using the drawString() in Java2D  and use the length for word wrapping.
33592
I have a group of strings in Javascript and I need to write a function that detects if another specific string belongs to this group or not.  What is the fastest way to achieve this? Is it alright to put the group of values into an array, and then write a function that searches through the array?  I think if I keep the values sorted and do a binary search, it should work fast enough. Or is there some other smart way of doing this, which can work faster?