I'm struggling with reading characters from console in c++.
Here is what I tried to do:
char x;
char y;
char z;
cout<<"Please enter your string: ";
string s;
getline(cin,s);
istringstream is(s);
is>> x >> y >> z;
The problem is if the user enter something like this "1 20 100":
x will get 1
y will get 2
z will get 0
What I want t...
Is there a way to search, from a string, a line containing another string and retrieve the entire line?
For example:
string =
qwertyuiop
asdfghjkl
zxcvbnm
token qwerty
asdfghjklñ
retrieve_line("token") = "token qwerty"
...
Spent some time troubleshooting a problem whereby a PHP/MySQL web application was having problems connecting to the database. The database could be accessed from the shell and phpMyAdmin with the exact same credentials and it didn't make sense.
Turns out the password had a $ sign in it:
$_DB["password"] = "mypas$word";
The password b...
I'm trying to write a unit test for a piece of code that generates a large amount of text. I've run into an issue where the "expected" and "actual" strings appear to be equal, but Assert.AreEqual throws, and both the equality operator and Equals() return false. The result of GetHashCode() is different for both values as well.
However, p...
I have select:
select v.accs, v.currency,v.amount,v.drcr_ind, count(*) qua,wm_concat(ids) npx_IDS,
wm_concat(px_dtct) npx_DTCT
from table v
group by accs, currency, amount, drcr_ind
but i get error ORA-06502: PL/SQL: : character string buffer too small if i'll remove one string, because sometimes (when v.accs= 3570) count(*) = 215
bu...
this error stops compiling if i have one or more System.String in my structs
is there any other way to store strings?
i have tried things like this:
private long _B_ID;
private byte[] _C_Name;
private byte[] _C_Address;
private byte[] _C_Telephone;
but it is not seeming to work.
...
I'm looking for a way to split a string containing HTML in to two halves. Requirements:
Split a string by a number of chars
Must not split in the middle of a word
Must not include HTML chars when calculating where to split the string
For example take the following string:
<p>This is a test string that contains <strong>HTML</strong> ...
With FluentValidation, is it possible to validate a string as a parseable DateTime without having to specify a Custom() delegate?
Ideally, I'd like to say something like the EmailAddress function, e.g.:
RuleFor(s => s.EmailAddress).EmailAddress().WithMessage("Invalid email address");
So something like this:
RuleFor(s => s.DepartureD...
Question: I need to call a C# dll from a C++ executable.
I use COM, and it works fine for int, long and bool. But I can't get a string along...
The IDL file says it's a BSTR, but I can't pass it correctly, and neither retrieve one.
I tried using wchar_t* and using sysalloc as I did with VB6, but that doesn't seem to work.
Anybody knows...
I have this array, for example (the size is variable):
x = ["1.111", "1.122", "1.250", "1.111"]
and I need to find the most commom value ("1.111" in this case).
Is there an easy way to do that?
Tks in advance!
EDIT #1: Thank you all for the answers!
EDIT #2: I've changed my accepted answer based on Z.E.D.'s information. Thank...
I'm having some trouble compiling some VB code I wrote to split a string based on a set of predefined delimeters (comma, semicolon, colon, etc). I have successfully written some code that can be loaded inside a custom VB component (I place this code inside a VB.NET component in a plug-in called Grasshopper) and everything works fine. F...
it works fine on 64 bit machines but for some reason will not work on python 2.4.3 on a 32-bit instance.
i get the error
'utf8' codec can't decode bytes in position 76-79: invalid data
for the code
try:
str(sourceresult.sourcename).encode('utf8','replace')
except:
raise Exception( repr(sourceresult.sourcename ) )
...
I'm trying to write the equivalent of strchr, but with NSStrings... I've currently got this:
Boolean nsstrchr(NSString* s, char c)
{
NSString *tmps = [NSString stringWithFormat: @"%c", c];
NSCharacterSet *cSet = [NSCharacterSet characterSetWithCharactersInString: tmps];
NSRange rg = [s rangeOfCharacterFromSet: cSet];
ret...
Hello,
Long.parseLong( string ) throws an error if string is not parsable into long.
Is there a way to validate the string faster than using try-catch?
Thanks
...
Error
% javac StringTest.java
StringTest.java:4: variable errorSoon might not have been initialized
errorSoon[0] = "Error, why?";
Code
public class StringTest {
public static void main(String[] args) {
String[] errorSoon;
errorSoon[0] = "Error, why?";
}
}
...
I have a program which places structures in a linked list based on the 'name' they have stored in them.
To find their place in the list, i need to figure out if the name im inserting is earlier or later in the alphabet then those in the structures beside it.
The names are inside the structures, which i have access to.
I don't need a fu...
I want to provide some template for a code generator I am developing. A typical pattern for class is :
public ${class_type} ${class_name} extends ${super_class} implements ${interfaces} {
${class_body}
}
Problem is if super_class is blank or interfaces. I replace extends ${super_class} with empty string. But I get extra spaces. So a...
How to match the string "Net Amount" (between Net and Amount there can be any number of spaces, including zero) with net amount?
Spaces between these two words can be any whitespace and exact matching of two string should be there. But Net Amount (first string with spaces) can be part of any string like Rate Net Amount or Rate Co...
I'd like to use this method to create user-friendly URL. Because my site is in Croatian, there are characters that I wouldn't like to strip but replace them with another. Fore example, this string:
ŠĐĆŽ šđčćž
needs to be:
sdccz-sdccz
So, I would like to make two arrays, one that will contain characters that are to be replaced and other ...
I have a program I am trying to debug, but Dynamic C apparently treats strings differently than normal C does (well, character arrays, anyway). I have a function that I made to make an 8 character long (well, 10 to include the \0 ) string of 0s and 1s to show me the contents of an 8-bit char variable. (IE, I give it the number 13, it r...