Split Everything before a particular pattern

I have a String Jon, Kim, Hem, David, Gary, Bryan, Otis, Neil, Blake, Greg, @Team=Cowboys, Chargers, Panthersm, Royals, Kings, Warriors I want to split this string in java from all commas before @Team appears. The result should look like: Jon Kim...
more »

2017-03-25 07:03 (3) Answers

C: Use scanf() function instead of gets

/* hexadecimal to decimal conversion */ #include <stdio.h> #include <math.h> #include <string.h> int main() { char hex[17]; long long decimal; int i , val, len; decimal = 0; // Input hexadecimal number from user printf("E...
more »

2017-03-24 16:03 (3) Answers

Assigning lexical order score to strings

In my current project we have a strange kind of sorting system. As opposed to the usual way of determining the order of elements by comparing them to one another, we first assign a numeric score to each element and then sort by this score. This way...
more »

2017-03-24 11:03 (3) Answers

Counting number of vowels in input of given words

Count the number of vowels in a word Please write a program to count how many vowels (‘a’, ‘e’, ‘i’, ‘o’, ‘u’) in a list of input words. Your program reads the words one by one and prints the number of vowels occurring in each wor...
more »

2017-03-24 11:03 (1) Answers

Assembly how to compare strings

for a small assignment we have to compare strings we were given this code in C extern "C" { bool isStringEqual(const char *s1, const char *s2); } static char *testStrings[] = { "", "Test String 1", "Test String 2", }; #define NUM_TE...
more »

2017-03-24 08:03 (0) Answers

VBA Function Return string type mismatch error

I'm writing a macro in VBA for Excel 2010. I feel as though I am missing something basic in my understanding. I've filled a string array and iterating over the contents in that array. The text in the array comes from an html formatted email messag...
more »

2017-03-24 04:03 (1) Answers

numerical order but longest digit first

Say I have an array of Strings like: 1000 2000 100 200 20 10 how can I order them so that the first digits are ordered numerically, yet it's the longest first? e.g. 1000 100 10 2000 200 20 (This may be trivial but I just can't think of anythin...
more »

2017-03-23 16:03 (1) Answers

Haskell: Couldn't match type `[Char]' with `Char'

I want a program that takes a text and changes some words, in particular it should write "Leonardo" every time it reads "Chiara" and vice-versa. This is my code: changeText [] = [] changeText (x:xs) | x == "C" = isChiara x xs | x == "L" = isLeo ...
more »

2017-03-23 15:03 (2) Answers

Add header row in excel when string changes

I have an excel worksheet that has a column "A" with a string path in it like this: foo\bar foo\bar foo\bar foo\bar foo\bar foo\widget foo\widget foo\widget foo\zelda foo\zelda foo\zelda I need to add a header row before each change in the path so...
more »

2017-03-20 21:03 (1) Answers

Why String Deduplication when we have String Pool

String De-duplication: Strings consume a lot of memory in any application.Whenever the garbage collector visits String objects it takes note of the char arrays. It takes their hash value and stores it alongside with a weak reference to the array....
more »

2017-03-20 19:03 (6) Answers

A way to override what 'type()' reports

Is there a way to alter a CLASS OBJECT so that type(object) reports a custom string? class MyClass(object): def __init__(self, t): if 'detector' in t: my_type_string = "I am set as a detector." else: my_ty...
more »

2017-03-20 16:03 (2) Answers

C char array v C char* initialization

The following is accepted as valid c code by gcc version 6.3: char white[] = { 'a', 'b', 'c' }; char blue[] = "abc"; char *red = "abc"; However the following fails: char *green = { 'a', 'b', 'c' }; // gcc error I am sure there is a perfe...
more »

2017-03-20 15:03 (2) Answers

Java Regex : match whole word with word boundary

I am trying to check whether a string contains a word as a whole, using Java. Below are some examples: Text : "A quick brown fox" Words: "qui" - false "quick" - true "quick brown" - true "ox" - false "A" - true Below is my code: String pattern = ...
more »

2017-03-20 14:03 (2) Answers

login with Do..while loop in C

I need to make a program that asks for a username and password and if they are both correct continue to a menu. Currently inputting a correct username and wrong password for some reason still prompts me to the menu, however if i input a wrong usernam...
more »

2017-03-20 11:03 (4) Answers

Interview questions about string and char

I faced two questions from a company. The two questions confused me. Can anyone help explain the reason of the answers? Write the result. void Test(void){ char *str = (char *) malloc(100); strcpy(str, “hello”); free(str); if(str != NUL...
more »

2017-03-20 10:03 (3) Answers

Very simple cryptography function in C

I'm trying to create a very simple cryptography function that takes a character array and returns another character array with its value increased by one. Precise explanation: The input is a line of text inserted by the user. I expect that the array...
more »

2017-03-19 08:03 (4) Answers