eval() for Android for String validation

I know similar questions are asked on SO, but none of the solutions work for me. I have a server response which sends me some variable names & their validations !! ie; for ex: it sends me field "username", type: "String" & validation : "us...
more »

2017-01-11 09:01 (0) Answers

Find an email address in a string in PHP

I wondered if anyone has any idea how to best do this in php. I have a string in a variable and I want to pull an email address from it (if one exists). The string could be along the lines of : "My email address is myemail@mydomain.com and I would...
more »

2017-01-10 18:01 (1) Answers

rindex in Swift 3

I think, there is no builtin function rindex (like in perl) to get the position of the last occurrence of a character in a string. I tried in a naive way like this func rindex (_ s:String, _ needle:Character) -> Int? { var pos = s.characters.c...
more »

2017-01-10 00:01 (1) Answers

String from BufferedReader not splitting?

Right now I'm programming a little chat history plugin for a game, in which I want to save all messages and the time it was sent in a file, which is working perfectly, but when reading it I'm getting a little problem. variables: history = new HashMap...
more »

2017-01-09 19:01 (1) Answers

VS2013: strtof doesn't set ERANGE?

In Visual Studio 2013, I have the following test code: #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main ( int argc, const char* argv[]) { static const char* floatStr = "3.402823466385...
more »

2017-01-09 01:01 (1) Answers

How to store '\0' in a char array

Is it possible to store the char '\0' inside a char array and then store different characters after? For example char* tmp = "My\0name\0is\0\0"; I was taught that is actually called a string list in C, but when I tried to print the above (using p...
more »

2017-01-08 18:01 (2) Answers

Order based on the number present in the text

this is my first time using this site. I am working on a code, which I am trying to solve. I am unable to get the output as required. This is about sorting arrays. I know that I should be using array.sort(), but I have to use a custom code to sort th...
more »

2017-01-06 23:01 (4) Answers

Finding specific strings in an array using R

I am trying to find if there is a quick way to search for specific strings in arrays in R, kind of like the game Boggle, except you know the word upfront. You are allowed to move in the following directions for the next letter of the string: up, dow...
more »

2017-01-06 15:01 (3) Answers

Validate string based on alternative 0's and 1's

I am trying to write a method that takes string as input and gives output as valid number of sub strings that can be produced from it, the string will have only 0's and 1's, sub strings formed will only be of length even. Valid Sub String Scenario: ...
more »

2017-01-05 17:01 (1) Answers

Why doesn't both these codes give the same output?

So I want draw a field (of array strings) with obstacles and free spaces. "+" are the obstacles and free spaces are just "". And if we have a free space, I want it replaced by "*". I will choose one specific element of that 2d array that equals "" an...
more »

2017-01-05 11:01 (4) Answers

De-referencing char pointer run-time error

Why does the below code cause a run-time crash? The code itself is not very useful, but , by creating a pointer to a char pointer and pointing to string literals in main, passing this pointer to my function and trying to read the strings causes pro...
more »

2017-01-04 16:01 (1) Answers

Range of unicode characters GHC accepts

This may sound a bit ridiculous, but GHC fails to compile my string containing bacon, a croissant, cucumber, and a potato: main = putStrLn "🥓 🥐 🥒 🥔" I realize I could easily write main = putStrLn "\x1F953 \x1F950 \x1F952 \x1F954...
more »

2017-01-03 08:01 (1) Answers

Replace a letter with its alphabet position

This looked fairly straightforward to me when I started, but for some reason I'm getting an empty array everytime I try to run the result on codewars. I'm hoping you can help me identify what the problem is. function alphabetPosition(text) { ...
more »

2017-01-02 13:01 (9) Answers

Defining a string as in fprintf syntax

How to build up a string in C that includes parameters? Is there a way similar to fprintf syntax to do it? For example here's a little testProg.c: int main(int argc, char *argv[]) { printf("You are running %s program.\n", argv[0]); // It will ...
more »

2017-01-02 10:01 (1) Answers

Public Function

I get an error on my class [31-Dec-2016 20:05:53 Africa/Casablanca] PHP Parse error: syntax error, unexpected 'Private' (T_PRIVATE), expecting identifier (T_STRING) in /home/address/main.php on line 5 Haven't added anything to the class yet ...
more »

2016-12-31 21:12 (1) Answers

putchar() function: ambiguous output

Here is a simple code , trying to clear spaces from character array, but output is not like I did expect "YasserMohamed". #include<stdio.h> int main() { char x[]="Yasser Mohamed"; char ch; int i=0; while (x[i]!='\n') { ...
more »

2016-12-31 12:12 (7) Answers