I need to see if a string value matches with an object value, but why won't this work?
public int countPacks(String flavour) {
int counter = 0;
for(int index = 0; index < packets.size(); index++) {
if (packets.equals(flavour)) {
counter ++;
}
else {
System.out.println("Yo...
I always try to avoid to return string literals, because I fear they aren't defined outside of the function. But I'm not sure if this is the case. Let's take, for example, this function:
const char *
return_a_string(void)
{
return "blah";
}
Is this correct code? It does work for me, but maybe it only works for my compiler (gcc). ...
Hi
I want to use LabVIEW's Call Library Function Node to access a DLL function, and have this function return a string to displayed on my VI. How would I go about doing this? I am quite happy returning numbers from my DLL, but am really struggling to find any examples of how to return a string.
...
I'm using MessageFormat to format some addresses with a template like this:
"{0}\n{1}\n{2}\n{3}, {4} {5}"
where
0 = street 1
1 = street 2
2 = street 3
3 = city
4 = state
5 = zip
Most of these fields are optional when captured. How do I avoid having an empty line when for instance, there is not street 3? I could use a template lik...
I have a char array buffer that I am using to store characters that the user will input one by one. My code below works but has a few glitches that I can't figure out:
when I execute a printf to see what's in Buffer, it does fill up but I get garbage characters at the end
it won't stop at 8 characters despite being declared as char Bu...
hi
i want something like this
the user enter a website link
i need check the link if the link
doesn't start with 'http://' I want
to append 'http://' to the link .
how can I do that in PHP ?
...
char *strtok(char *s1, const char *s2)
repeated calls to this function break string s1 into "tokens"--that is
the string is broken into substrings,
each terminating with a '\0', where
the '\0' replaces any characters
contained in string s2. The first call
uses the string to be tokenized as s1;
subsequent calls use NUL...
Hi all,
I have a very painful library which, at the moment, is accepting a C# string as a way to get arrays of data; apparently, this makes marshalling for pinvokes easier.
So how do I make a ushort array into a string by bytes? I've tried:
int i;
String theOutData = "";
ushort[] theImageData = inImageData.DataArray;
//this is as ...
I wish to convert a single string with multiple delimiters into a key=>value hash structure. Is there a simple way to accomplish this? My current implementation is:
sub readConfigFile() {
my %CONFIG;
my $index = 0;
open(CON_FILE, "config");
my @lines = <CON_FILE>;
close(CON_FILE);
my @array = split(/>/, $lines[0]);
my $total = @...
Hi in C++ if i have a string, how can I split this into tokens?
...
Hi, I'm pretty sure this is a simple question in regards to formatting but here's what I want to accomplish:
I want to output data onto the screen using cout. I want to output this in the form of a table format. What I mean by this is the columns and rows should be properly aligned. Example:
Test 1
Test2 ...
var pattern = /^0+$/;
My guess is this:
"Take a look at both the beginning and the end of the string, and if there's a pattern of one or more zeros at the beginning and the end, then return that pattern."
I'm sure that's wrong, though, because when I run the expression with this string:
var string = "0000009000000";
It comes up nu...
Duplicate:
How do I tokenize a string in C++?
I have a character array in C++.
arr="abc def ghi"
I want to get the strings "abc" "def" "ghi" out of the string. Are there any built in functions to do this?
...
I'm trying to split a string with all non-alphanumeric characters as delimiters yet Java's String.split() method discards the delimiter characters from the resulting array. Is there a way to split a string like the "\W" regex pattern does, yet keep the delimiters?
...
I want to write a regular expression that will replace the word Paris by a link, for only the word is not ready a part of a link.
Example:
i'm living <a href="Paris" atl="Paris link">in Paris</a>, near Paris <a href="gare">Gare du Nord</a>, i love Paris.
would become
i'm living.........near <a href="">Paris</a>..........i ...
I want to read a mac id from command line and convert it to an array of uint8_t values to use it in a struct. i can not get it to work. i have a vector of string for the mac id split about : and i want to use stringstream to convert them with no luck. can anyone point me what i am missing?
int parseHex(const string &num){
stringstre...
I wrote this function that's supposed to do StringPadRight("Hello", 10, "0") -> "Hello00000".
char *StringPadRight(char *string, int padded_len, char *pad) {
int len = (int) strlen(string);
if (len >= padded_len) {
return string;
}
int i;
for (i = 0; i < padded_len - len; i++) {
strcat(string, pad);
...
I've been reading through the details of the System libraries set and get methods yet the parameters are usually Strings.
Would you consider the use of String as parameters bad practise since the inclusion of enum?
A better alternative at minimum might be public final String, No?
...
In Python, if I do this:
print "4" * 4
I get
> "4444"
In Perl, I'd get
> 16
Is there an easy way to do the former in Perl?
...
My lack of C++ experience, or rather my early learning in garbage collected languages is really stinging me at the moment and I have a problem working with strings in C++.
To make it very clear, using std::string or equlivents is not an option - this is char* 's all the way.
So: what I need to do is very simple and basically boils down...