Tagged Questions

A String is a sequence of zero or more characters. It is commonly used to represent text.

learn more… | top users | synonyms (1)

8
votes
2answers
132 views

Is this a proper way of programming in c#?

I have a menu, where a user selects one out of 4, and another 2 or 4 options will appear. I used big buttons; a picturebox + label to create the buttons. The 4 main buttons are fixed, but the 4 other ...
3
votes
0answers
36 views

Print all permutations with repetition of characters

Given a string of length n, print all permutation of the given string. Repetition of characters is allowed. Print these permutations in lexicographically sorted order Examples: Input: AB ...
5
votes
2answers
105 views

reverse every word in a string(should handle space)

Examples: char test1[] = " "; char test2[] = " hello z"; char test3[] = "hello world "; char test4[] = "x y z "; Results: " " " olleh z" "olleh dlrow " "x ...
0
votes
2answers
55 views

symmetric string checking [closed]

I wrote this routine in C to check the symmetry of a string using only a stack. (This is absolutely for educational purpose in our Theory Of Computation Class) Anyways, does this look right? For some ...
2
votes
1answer
29 views

Implement numbering scheme like A,B,C… AA,AB,… AAA…, similar to converting a number to radix26

I want to implement numbering scheme like Microsoft Word uses for numbering. first one gets = A,next is B, next is C, .... then AA, then AB,....and so on. as shown below A B C . . AA ...
3
votes
0answers
89 views

Parsing XML to create IList

Here's a class I created to parse XML to create an IList. It seems to me that this is something that will be done a lot in general by a lot of different programs. Is there a more standard way of doing ...
4
votes
4answers
106 views

Title case name when first,middle and last are all upper or lower case

This code works, but i get the feeling that it could be shorter and simpler. Any ideas? private void CheckNameCase(Models.PersonalInformationModels.PersonalInformationModel model) { // if first ...
3
votes
1answer
85 views

CoffeeScript date formatting

forceTwoDigits = (val) -> if val < 10 return "0#{val}" return val formatDate = (date) -> year = date.getFullYear() month = forceTwoDigits(date.getMonth()+1) day = ...
4
votes
2answers
117 views

Reading a line from a text file and splitting its contents

I have this kind of file structure MALE:FooBar:32 FEMALE:BarFoo:23 Where I would want to identify the gender and age of person, <Gender>:<Name>:<age> try{ BufferedReader in = ...
6
votes
5answers
765 views

C++ program to count the number of occurrences of a word

I was selected for the third round of MS internships for third years. We were surprisingly asked a very easy question: “Make a program that counts the number of times the WORD "a" or "A" occurs”. I ...
5
votes
3answers
124 views

Scala: a safer way to cut string

I want to get just the first line of a big string. Currently, here's how I do it: def getFirstParagraph(txt: String) = { val newLineIdx = txt.indexOf("\n") match { case i: Int if i > 0 ...
2
votes
3answers
117 views

How to re-factor a common String comparison

Code below is scattered all over the code base : if (StringUtils.contains(manager.getName, "custom")){ } It just checks if an object attribute contains a predefined String and if it does, enter ...
0
votes
2answers
69 views

May be a memory leak somewhere or allocated memory not freed? [closed]

Here is the entire program, please help me, I've tried everything to find out what exactly is going with the memory. The problem is everything runs perfectly, but there are some extra characters ...
1
vote
2answers
246 views

Can this algorithm to find substring in string be further improved?

static int find(string term, string text) { int found = -1; int termIndex = 0; for (int textIndex = 0; textIndex < text.Length; textIndex++) { if ...
3
votes
1answer
146 views

Constant time string comparision in PHP to prevent timing attacks

I've been advised that when checking the password hash for a user I should use a string comparison function that always takes the same amount of time, to avoid timing attacks. So I wrote this: ...

1 2 3 4 5 7
15 30 50 per page