The tag has no usage guidance.

learn more… | top users | synonyms

-2
votes
0answers
21 views

Stripping one set of arrays and replacing quotes [on hold]

How could I take: s = [[0,0,0,0],[0,0,0,1]] and change it to: s = ["0,0,0,0","0,0,0,1"] Don't really mind how elegant it is.
11
votes
1answer
339 views

Why are C string literals read-only?

What advantage(s) of string literals being read-only justify(-ies/-ied) the: Yet another way to shoot yourself in the foot char *foo = "bar"; foo[0] = 'd'; /* SEGFAULT */ Inability to elegantly ...
0
votes
0answers
3 views

Beginner in C needing help with strings and memory [migrated]

So this course I'm doing wants us to play around with memory management and pointers. I'm not really fully understanding them. I keep getting a "Segmentation fault (Core dumped)" error. Apparently I ...
0
votes
1answer
151 views

Why are Strings in StringPool considered insecure?

Passwords are recommended to be stored in char[] instead of String, as Strings are stored in StringPool. Read more here As per this question Strings in StringPool are not available directly. To ...
3
votes
2answers
134 views

Are string characters assigned a numerical value in context of how they are assigned in a programming language?

For context I am fairly new to programming after returning back to it after programming a number of years ago... I was reading Bjarne's intro programming with C++ and was wondering if alphabetical ...
3
votes
2answers
74 views

why regex, when using global search and {0,} quantifier, match the end of the string?

I have asked a question here about js, regex, quantifiers and global search. I've understood finally how this works, but, let's take a concrete example and then I`ll write my question. Based on the ...
1
vote
0answers
46 views

clustering of strings with variable-length prefixes

I've got bunch of strings with variable-length prefixes (or postfixes - I can always revert them) as follows: 0155555555 523455555555 755555555 ... 87129999999999999 119999999999999 09119999999999999 ...
0
votes
2answers
177 views

Why can't I use an operator like plus sign to concatenate strings? [closed]

Why in Objective-C we should be typing explicit references to methods like stringByAppendingString to concatenate strings, when in some other languages we can use operators for that? For example, ...
0
votes
2answers
178 views

Why should I use lookup tables at all?

This question confirmed, what I was already aware of -- instead of directly storing strings in table, I should rather use integers or enums and join them with lookup table, to get, as a result, ...
2
votes
3answers
133 views

At which point using string-based enums can become a real problem?

This is a direct follower to this question. An answer given to that questions says (my understanding), that nowadays using string-based enums instead of integers isn't a much problem, because hosting ...
1
vote
4answers
338 views

How can I avoid the use of strings?

I'm implementing a program where the user can 'create a musical scale' from a variety of notes (identified by their names), and the program will generate music from this scale. I want to implement a ...
1
vote
0answers
34 views

String Rearrangement Algorithm in Visual Basic

Beginning programmer here (mostly engineer). I'm making trapezoids in layers. We begin with the small length layer, and end with the longest length layer. I want my user to input in a desired ...
5
votes
1answer
63 views

Use StringLike instead of String in Scala?

Scala has the StringLike trait. Let's say I want to create a case class Name and internally it should save the name with some characters. Should I use case class Name(name: StringLike) or case class ...
38
votes
6answers
7k views

Hardcoding strings that will never change

So, in my efforts to write a program to conjugate verbs (algorithmically, not through a dataset) for French, I've come across a slight problem. The algorithm to conjugate the verbs is actually fairly ...
11
votes
2answers
580 views

Why store flags/enums in a database as strings instead of integers?

I've been browsing SQL dumps of some famous CMSes, including Drupal 7, Wordpress (some quite very old version), and some custom application based on Python. All of these dumps contained data with ...
0
votes
2answers
147 views

Detecting and Dealing with obscene language in user input

I've seen some pretty darned restrictive 'chat-systems' in kids games, that make it nigh-on-impossible to get much of a message across whilst typing. So, I looked at some ideas, and there where two ...
0
votes
0answers
76 views

Compare names and the use of Levenshtein's algorithm

I need to cross names from two lists. What is the best away to compare the names? As you may expect, in one list we can have the complete name, on the other just the first and last. Besides that, ...
0
votes
5answers
510 views

Is String processing more complex than number processing in programming languages?

I feel that string processing is always more complex than Numbers or mathematical processing. Are our programming languages are designed this way that mathematical operations are pretty much straight ...
0
votes
1answer
168 views

Making a database and related operators using files and JSON in java [closed]

I'm trying to write a program that reads operations from a file. these operators look like below : CREATE TABLE student(id:integer, gpa:decimal, name:string, family:string,isMale:Boolean) INSERT ...
-2
votes
1answer
164 views

Does datetime.fromtimestamp() return a datetime object or a string?

Basically what the title says. This is a more theoretical question than anything, I don't have a specific use for it. I've looked up the documentation and I can't find a definite answer.
3
votes
2answers
6k views

Which way is more efficient for getting the space count?

I have just started reading Cracking the Coding Interview. One of the problems (specifically 1.4) after solving and then looking at the answer made me question the way it is done and decided to post ...
2
votes
4answers
1k views

How to automatically connect letters into words? [closed]

I would like to connect letters into meaningful words? E.g. input: T E ST IN G WE B A P P LIC AT IO N S output: TESTING WEB APPLICATIONS what kind of task is this? A task in NLP, or just some ...
4
votes
2answers
447 views

Number of strings containing a specific substring

I've seen numerous questions (and answers) concerning the number of binary strings (e.g "10010" containing some binary substring (e.g "00"). I'd like to know if there is a way to generalize this: ...
6
votes
3answers
191 views

number of strings, when each character must occur even times

I've been bashing my skull at this problem for some time now, and its really starting to frustrate me. The problem is: I have a set of characters, A, B, C, and D. I have to tell in how many ways a ...
2
votes
1answer
173 views

Functions returning strings, good style?

In my C programs I often need a way to make a string representation of my ADTs. Even if I don't need to print the string to screen in any way, it is neat to have such method for debugging. So this ...
0
votes
3answers
175 views

Should I be extracting strings from source in core java the way android does?

I just started doing android development stuff after getting pretty comfortable with Java. Android apps tend to do this weird thing where they have all strings for their program held in an XML file ...
0
votes
6answers
328 views

Why 'String' objects are immutable with an explicit constructor in java? [duplicate]

It make sense to make class String objects immutable with following declarations, because they share the same storage in common pool. String str1 = "abc"; String str2 = "abc"; But, am not sure, if ...
0
votes
1answer
34 views

String splits to create arrays

Creating an array of strings for configuration or verification purposes can get long and ugly in code. For example: arrayOfStrings = ['one','two','three','four'] Often to reduce the characters and ...
2
votes
1answer
39 views

performance issues when synchronizing on an interned String

I want to lock a remote file with the string "ip + filename" using java. public boolean execCmd(String ip,String filename, String command) { String file = ip + filename; String lock = ...
1
vote
2answers
114 views

Return equal occurrence of char in a list of strings

I have an array of strings ["abb", "bbxxaa"]. I would like to print all characters that occur equal times in each index so in above case I would print bb because they occur twice in both indexes and ...
4
votes
1answer
176 views

Understanding Boyer-Moore Algorithm

Edit: I've found the original publication. It seems to me that the original does not have a l′(i). But I could be wrong because the definition of rpr(i) is so obscure to me. I'm not sure how it makes ...
5
votes
2answers
346 views

Is there any language-agnostic specification for “String Natural Sorting Order”

As I painfully try to find a good natural sorting algorithm written in JavaScript I then stumble upon a bunch of different implementations, & interesting blog posts & answers on Stack ...
3
votes
1answer
155 views

How to fix legacy code that uses <string.h> unsafely?

We've got a bunch of legacy code, written in straight C (some of which is K&R!), which for many, many years has been compiled using Visual C 6.0 (circa 1998) on an XP machine. We realize this is ...
-3
votes
2answers
4k views

How does std::string in c++ allocate memory? [closed]

I've noticed that the string library doesn't require one to allocate space before writing the input/output. How does the string library allocate that memory dynamically, i know of the 'new' keyword in ...
1
vote
2answers
172 views

Is there a stricter strtoull() in any ubiquitous C library?

I want a function that will interpret a string as a strictly unsigned integer, failing when the string overflows, represents a negative number, or does not represent a number. strtoull() does set ...
0
votes
1answer
2k views

VB.NET - Serial Key Generating (Encryption, Hashing, Encoding?) Algorithm

I am trying to create a basic licensing system where I take a unique ID from the client computer, and I get this Hexadecimal string (hyphens removed e.g. "84-18-CE-...."): ...
-2
votes
2answers
2k views

Assigning strings to pointer in C Language

I am a new learner of C language, my question is about pointers. As far i learned and searched pointers can only store addresses of other variables, but cannot store the actual values(like integers or ...
-1
votes
1answer
97 views

Choosing a file format to storage a simple text data [closed]

My .NET application makes its work and then creating a report (an Excel worksheet). The report holds thousands of short text strings [KEY - VALUE], so excel worksheets suites very well, one column ...
1
vote
4answers
3k views

Regex to String generation

Let's say that we have a regex and an index i. If we suppose that the set of strings that match our regex are sorted in a lexicographical order, how could we get the i element of this list? Edit : I ...
0
votes
1answer
102 views

exception for string literal conventions

If I'm used to use ' for string literals in PHP, would it be better if I'll stick to it in any situation or can there be exceptions when it would increase readability? example: $foo = "bar'baz"; // ...
1
vote
2answers
3k views

Why doesn't Ruby have implicit conversion of Fixnum into String?

Ruby normally makes things easy. However, it doesn't allow implicitely converting a number to a string: 2.0.0p247 :010 > "a"+1 TypeError: no implicit conversion of Fixnum into String Why is this ...
1
vote
1answer
237 views

Algorithm to create permutations for a given alphabet based on a sequence number

I would like to have a function that will create a word (always the same word) for a given sequence number based on a given alphabet. word(0, [a,b,c]) = a word(1, [a,b,c]) = b word(2, [a,b,c]) = c ...
-1
votes
2answers
637 views

Word recognition in a string without spaces or punctuation marks

I have a small C# project that reads a file and gives me an output: a string that does not contain spaces nor any types of punctuation marks. It may also contain a few misspellings. Ex. Output: ...
1
vote
2answers
263 views

What's the difference of an object being final and an object being immutable in java?

final String str = "do not change me"; str = "why not?"; //it will result in compile time error saying that final fields can not be re-assigned once created i.e. the reference cannot be changed ...
0
votes
3answers
183 views

How can I handle this string concatenation in C in a reusable way

I've been writing a small C application that operates on files, and I've found that I have been copy+pasting this code around my functions: char fullpath[PATH_MAX]; fullpath[0] = '\0'; ...
0
votes
0answers
225 views

What is the purpose of chunking strings in natural language processing?

I see many examples of libraries that use a 'chunker' and also people asking how to write chunkers, but what is this for and why do we need it? Isn't it enough to split a text by whitespace or other ...
6
votes
5answers
1k views

Why doesn't Haskell have a 'format' function for string interpolation?

I'm trying to use Shake and I stumbled upon the following problem: there's no easy and convenient way to interpolate a string. I know about Text.Printf — it's not what I'm looking for. The ...
1
vote
4answers
407 views

How can I take a list of tokens (of variable number) and know what each token means?

I have to read a text document with data formatted as follows: (a couple of examples) 07 M W F 1400 1450 C 2004 M W F 0900 1030 EN 2036 06 M T R 1300 1350 EN 1003 17 T R 0900 1015 EN 1052 The ...
1
vote
1answer
149 views

Search Substring in String collection

I have a big collection of strings a[1], …, a[N] where N is about several millions. I am provided a string m and I need to iterate over all the strings a[i] that contain m. In other words, I need to ...
14
votes
3answers
2k views

How many strings are created in memory when concatenating strings in Java?

I was asked about immutable strings in Java. I was tasked with writing a function that concatenated a number of "a"s to a string. What I wrote: public String foo(int n) { String s = ""; for ...