473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

splitting two arrays.

Hi there.

I'm trying to do the following.

I have a string, and i want to separate it into other halves.
This is how it should be:

char string[] = "test//test2//test3";

were // is the part were i want to separate it and store on a
bidimensional array like name[50][65],

were 50 diferent names are allowed, each name have 65 bytes of length.

i know how to copy the first bytes until the first //

How can it do to split the string and insert it in name in this onder

name[0] = test
name[1] = test2
name[3] = test3
........
........

thanks in advance for any help.

Regards

Oct 31 '06 #1
13 1939
Pedro Pinto said:
Hi there.

I'm trying to do the following.

I have a string, and i want to separate it into other halves.
This is how it should be:

char string[] = "test//test2//test3";

were // is the part were i want to separate it and store on a
bidimensional array like name[50][65],

were 50 diferent names are allowed, each name have 65 bytes of length.

i know how to copy the first bytes until the first //

How can it do to split the string and insert it in name in this onder

name[0] = test
name[1] = test2
name[3] = test3
Look up strchr and memcpy.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 31 '06 #2
In <11**********************@h48g2000cwc.googlegroups .com"Pedro Pinto" <ku*****@gmail.comwrites:
Hi there.
I'm trying to do the following.
I have a string, and i want to separate it into other halves.
This is how it should be:
char string[] = "test//test2//test3";
were // is the part were i want to separate it and store on a
bidimensional array like name[50][65],
were 50 diferent names are allowed, each name have 65 bytes of length.
i know how to copy the first bytes until the first //
How can it do to split the string and insert it in name in this onder
name[0] = test
name[1] = test2
name[3] = test3
Try strtok(). strtok() is a function that splits a string into pieces,
based on a separation string you provide.

char string[] = "test//test2//test3";
char name[50][65];
char *tmp;
int i = 0;

tmp = strtok(string, "//");
strcpy(name[0], tmp);

while(tmp = strtok(NULL, "//"))
strcpy(name[++i], tmp);

--
John Gordon "It's certainly uncontaminated by cheese."
go****@panix.com

Oct 31 '06 #3
In article <ei**********@reader2.panix.com>,
John Gordon <go****@panix.comwrote:
>Try strtok(). strtok() is a function that splits a string into pieces,
based on a separation string you provide.
Not -exactly-.

char string[] = "test//test2//test3";
Note to the original poster: it is important in this example
that the type is char string[] and not char *string .
In the form that John gave, string[] will be writable; if he
had used char *string = "test//test2//test3"; then string[]
would be read-only, which would cause a problem with strtok() as
strtok() modifies the string itself.
char name[50][65];
char *tmp;
int i = 0;
tmp = strtok(string, "//");
The second argument to strtok() is not a a literal string to match
against (in this example, the character pair // ). The second argument
to strtok() is instead a string, each character of which is to be treated
as a delimiter for tokenization. For example strtok() with ":/" as
the second argument would stop the tokenization at any character
position that was a ':' or a '/'. Specifying "//" is thus the same
as specifying just "/" and each of the '/' encountered would
act as a delimiter. For example, a/b//test2 would break down
into the tokens "a" "b" and "test2"
strcpy(name[0], tmp);

while(tmp = strtok(NULL, "//"))
strcpy(name[++i], tmp);
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
Oct 31 '06 #4
In <ei**********@canopus.cc.umanitoba.caro******@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:
tmp = strtok(string, "//");
The second argument to strtok() is not a a literal string to match
against (in this example, the character pair // ). The second argument
to strtok() is instead a string, each character of which is to be treated
Doh! I've been too long away from C.

--
John Gordon "It's certainly uncontaminated by cheese."
go****@panix.com

Oct 31 '06 #5
Richard Heathfield wrote:
Pedro Pinto said:
>Hi there.

I'm trying to do the following.

I have a string, and i want to separate it into other halves.
This is how it should be:

char string[] = "test//test2//test3";

were // is the part were i want to separate it and store on a
bidimensional array like name[50][65],

were 50 diferent names are allowed, each name have 65 bytes of length.

i know how to copy the first bytes until the first //

How can it do to split the string and insert it in name in this onder

name[0] = test
name[1] = test2
name[3] = test3
I think name[2] = test3, not name[3].
Look up strchr and memcpy.
Perhaps strstr would be more appropriate, given that the delimiter
consists of more than one character.

#include <stdio.h>
#include <string.h>

#define MAX_LEN 64
#define MAX_NAM 50

int main(void)
{
const char *delim = "//";
const char *string = "test//test2//test3";
const char *p = string, *q;
char name[MAX_NAM][MAX_LEN + 1];
int i, n = 0;
do {
if(n == MAX_NAM)
{
fprintf(stderr, "Too many names\n");
return 0;
}
q = strstr(p, delim); /* find next delim */
if(!q) q = strchr(p, '\0'); /* if no delim, end of str */
if(q - p MAX_LEN)
{
fprintf(stderr, "Name too long\n");
return 0;
}
memcpy(name[n], p, q - p); /* copy contents */
name[n][q - p] = '\0'; /* and null terminate */
n++;
if(*q) p = q + strlen(delim); /* if not end of str, skip delim */
} while(*q); /* repeat until end of string reached */
for(i = 0; i < n; i++)
{
printf("name[%d] = %s\n", i, name[i]);
}
return 0;
}

--
Simon.
Nov 1 '06 #6

John Gordon escreveu:
In <ei**********@canopus.cc.umanitoba.caro******@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:
tmp = strtok(string, "//");
The second argument to strtok() is not a a literal string to match
against (in this example, the character pair // ). The second argument
to strtok() is instead a string, each character of which is to be treated

Doh! I've been too long away from C.

--
John Gordon "It's certainly uncontaminated by cheese."
go****@panix.com
The solucion pointed by John works well but i have one last question!

Before i send my original string to the funtion, it has, lets supose,
16 of length. After the funtion it only has four!

Original string = "test/test1/test2
after use of funtion = "test"
i created this function to do the calculation far from main:

void divide(char search_string[], char *array[]){

int loop;

array[0]=strtok(search_string,"/");
if(array[0]==NULL)
{
printf("No test to search.\n");
exit(0);
}

for(loop=1;loop<50;loop++)
{
array[loop]=strtok(NULL,"/");
if(array[loop]==NULL)
break;
}

for(loop=0;loop<50;loop++)
{
if(array[loop]==NULL)
break;

printf("\narray[%d] = %s", loop,array[loop]);

}
}
thank you for the efford, i hope someday i will be able to help you!

Regards Pedro

Nov 1 '06 #7

Pedro Pinto wrote:
John Gordon escreveu:
In <ei**********@canopus.cc.umanitoba.caro******@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:
tmp = strtok(string, "//");
The second argument to strtok() is not a a literal string to match
against (in this example, the character pair // ). The second argument
to strtok() is instead a string, each character of which is to be treated
Doh! I've been too long away from C.

--
John Gordon "It's certainly uncontaminated by cheese."
go****@panix.com

The solucion pointed by John works well but i have one last question!

Before i send my original string to the funtion, it has, lets supose,
16 of length. After the funtion it only has four!
Read the manual page for strtok, carefully - one of its (many) foibles
is that it changes the string it is tokenizing.
Original string = "test/test1/test2
after use of funtion = "test"
Because strtok has converted the '/' characters into '\0' as it worked.

If this is a problem, clone your string (on some platforms, a strdup()
function is available for this purpose, otherwise you can use malloc
and strcpy()).

Alternatively you can use one of the strchr() based solutions discussed
elsewhere in the thread.

BTW, I note that your requirement has changed - you now use a single
'/' not a "//" string as a delimiter.

What do you intend to happen with "test/test1//test3" - does the
strtok() solution do what you want?

Nov 1 '06 #8
Pedro Pinto wrote:
John Gordon escreveu:
>In <ei**********@canopus.cc.umanitoba.caro******@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:
>>> tmp = strtok(string, "//");
The second argument to strtok() is not a a literal string to match
against (in this example, the character pair // ). The second argument
to strtok() is instead a string, each character of which is to be treated
Doh! I've been too long away from C.

--
John Gordon "It's certainly uncontaminated by cheese."
go****@panix.com

The solucion pointed by John works well but i have one last question!

Before i send my original string to the funtion, it has, lets supose,
16 of length. After the funtion it only has four!

Original string = "test/test1/test2
after use of funtion = "test"
That's one of the issues with strtok. It modifies the original string,
replacing the delimiters with null characters. The pointers it returns
to tokens are in fact pointers within your original string, but they are
smaller strings since they end on the null characters.

If you still want to use strtok, you're best to make a copy of the
string first:

char *duplicate_string(const char *a)
{
char *new = malloc(strlen(a) + 1);
if(!new) return NULL;
strcpy(new, a);
return new;
}

Also keep in mind that strtok considers adjacent delimiters as one.
There's no way to produce an empty token, for example:

"test/test1//test3" -{"test", "test1", "test3"}
but not {"test", "test1", "", "test3"}
i created this function to do the calculation far from main:

void divide(char search_string[], char *array[]){

int loop;

array[0]=strtok(search_string,"/");
if(array[0]==NULL)
{
printf("No test to search.\n");
exit(0);
}

for(loop=1;loop<50;loop++)
{
array[loop]=strtok(NULL,"/");
if(array[loop]==NULL)
break;
}

for(loop=0;loop<50;loop++)
{
if(array[loop]==NULL)
break;

printf("\narray[%d] = %s", loop,array[loop]);

}
}
Ok, this function is fine, but remember that the pointers that are
placed in your array are actually pointing into the original
search_string[] array.

After the function completes, the search_string[] array contains a
number of strings, one after the other, and pointers to the start of
each of these strings are placed into array[].

No extra memory was allocated to store your tokens; the text is still
sitting where is was in the first place, but the delimiters ('/'
characters) have been replaced by null characters ('\0').

--
Simon.
Nov 1 '06 #9
Simon Biber wrote:
Pedro Pinto wrote:
John Gordon escreveu:
>In <ei**********@canopus.cc.umanitoba.ca>
ro******@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:
>
tmp = strtok(string, "//");
The second argument to strtok() is not a a literal string to
match against (in this example, the character pair // ). The
second argument to strtok() is instead a string, each character
of which is to be treated
Doh! I've been too long away from C.
>
--
John Gordon "It's certainly uncontaminated by cheese."
go****@panix.com
The solucion pointed by John works well but i have one last
question!

Before i send my original string to the funtion, it has, lets
supose, 16 of length. After the funtion it only has four!

Original string = "test/test1/test2
after use of funtion = "test"

That's one of the issues with strtok. It modifies the original
string, replacing the delimiters with null characters. The pointers
it returns to tokens are in fact pointers within your original
string, but they are smaller strings since they end on the null
characters.
Also keep in mind that strtok considers adjacent delimiters as one.
There's no way to produce an empty token, for example:

I was going to refer the OP to an appropriate FAQ section, but
surprisingly there doesn't seem to be one for strtok() and tokenizing
issues in general.

It seems like one of those things that might be useful to have in the
FAQs, but I don't maintain it and don't wish to insist that Steve do
extra work to accomodate that interest.


Brian
Nov 1 '06 #10
On Thu, 02 Nov 2006 02:01:43 +1100, Simon Biber <ne**@ralmin.ccwrote:
>Pedro Pinto wrote:
>>John Gordon escreveu:
>>>In <ei**********@canopus.cc.umanitoba.caro******@ibd.nrc-cnrc.gc.ca
(Walter Roberson) writes:
tmp = strtok(string, "//");

The second argument to strtok() is not a a literal string to match
against (in this example, the character pair // ). The second argument
to strtok() is instead a string, each character of which is to be treated

Doh! I've been too long away from C.

The solucion pointed by John works well but i have one last question!

Before i send my original string to the funtion, it has, lets supose,
16 of length. After the funtion it only has four!

Original string = "test/test1/test2
after use of funtion = "test"

That's one of the issues with strtok. It modifies the original string,
replacing the delimiters with null characters. The pointers it returns
to tokens are in fact pointers within your original string, but they are
smaller strings since they end on the null characters.
I usually prefer strstr() and strcspn() for this sort of thing. When
delimiters are single characters, something like the following works
quite well, IMHO (the strcspn() function can also handle `empty fields',
when consecutive occurences of the separator characters are found):

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static const char *s = "test0//test3/test4//test6";
static const char *sep = "/";

int
main(void)
{
char **vec, **tmp;
size_t vsize, vlen;
const char *p;
size_t j, k, pos;

/*
* Allocate some initial space for vec[], which we'll grow
* afterwards as necessary.
*/
vsize = 1;
vec = malloc(vsize * sizeof *vec);
if (vec == NULL)
goto err;
vec[0] = NULL;

/*
* Split the string from `s' to a newly allocated vector
* of strings, stored in vec[]. The allocated size of
* vec[] is kept in `vsize' and the in-use part of vec[]
* is vec[0] ... vec[vlen-1] (a total of `vlen' elements).
*/
for (p = s, k = vlen = 0; p != NULL && *p != 0; k++) {
/* Find the position of the next separator. */
pos = strcspn(p, sep);

/* Make sure vec[] can fit another element. */
if (k >= vsize) {
tmp = realloc(vec, (2 * vsize) * sizeof *vec);
if (tmp == NULL)
goto err;
vec = tmp;
vsize *= 2;
for (j = vlen; j < vsize; j++)
vec[j] = NULL;
}
vec[k] = malloc((pos + 1) * sizeof(char));
if (vec[k] == NULL)
goto err;
memset(vec[k], 0, pos + 1);
strncpy(vec[k], p, pos);
vlen++;
p = p + pos + 1;
}

/* Print the resulting string vector. */
(void)printf("Initial string = \"%s\"\n", s);
for (k = 0; k < vlen; k++)
(void)printf(" Field %3zd = \"%s\"\n", k, vec[k]);

/* Clean up and exit. */
for (k = 0; k < vsize; k++) {
free(vec[k]);
vec[k] = NULL;
}
free(vec);
vec = NULL;
return EXIT_SUCCESS;

/*
* Clean up and print a warning that some memory allocation has
* failed (this may not work 100% correctly, because fprintf()
* may also fail to work on low-memory conditions :-/
*/
err:
if (vec != NULL) {
for (k = 0; k < vsize; k++) {
free(vec[k]);
vec[k] = NULL;
}
free(vec);
vec = NULL;
}
(void)fprintf(stderr, "Out of memory.\n");
return EXIT_FAILURE;
}
Nov 15 '06 #11
Giorgos Keramidas wrote:
On Thu, 02 Nov 2006 02:01:43 +1100, Simon Biber <ne**@ralmin.ccwrote:
>Pedro Pinto wrote:
>>John Gordon escreveu:
In <ei**********@canopus.cc.umanitoba.caro******@ibd.nrc-cnrc.gc.ca
(Walter Roberson) writes:
> tmp = strtok(string, "//");
The second argument to strtok() is not a a literal string to match
against (in this example, the character pair // ). The second argument
to strtok() is instead a string, each character of which is to be treated
Doh! I've been too long away from C.
The solucion pointed by John works well but i have one last question!

Before i send my original string to the funtion, it has, lets supose,
16 of length. After the funtion it only has four!

Original string = "test/test1/test2
after use of funtion = "test"
That's one of the issues with strtok. It modifies the original string,
replacing the delimiters with null characters. The pointers it returns
to tokens are in fact pointers within your original string, but they are
smaller strings since they end on the null characters.

I usually prefer strstr() and strcspn() for this sort of thing. When
delimiters are single characters, something like the following works
quite well, IMHO (the strcspn() function can also handle `empty fields',
when consecutive occurences of the separator characters are found):

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static const char *s = "test0//test3/test4//test6";
static const char *sep = "/";

int
main(void)
{
char **vec, **tmp;
size_t vsize, vlen;
const char *p;
size_t j, k, pos;

/*
* Allocate some initial space for vec[], which we'll grow
* afterwards as necessary.
*/
vsize = 1;
vec = malloc(vsize * sizeof *vec);
if (vec == NULL)
goto err;
vec[0] = NULL;

/*
* Split the string from `s' to a newly allocated vector
* of strings, stored in vec[]. The allocated size of
* vec[] is kept in `vsize' and the in-use part of vec[]
* is vec[0] ... vec[vlen-1] (a total of `vlen' elements).
*/
for (p = s, k = vlen = 0; p != NULL && *p != 0; k++) {
/* Find the position of the next separator. */
pos = strcspn(p, sep);

/* Make sure vec[] can fit another element. */
if (k >= vsize) {
tmp = realloc(vec, (2 * vsize) * sizeof *vec);
if (tmp == NULL)
goto err;
vec = tmp;
vsize *= 2;
for (j = vlen; j < vsize; j++)
vec[j] = NULL;
}
vec[k] = malloc((pos + 1) * sizeof(char));
if (vec[k] == NULL)
goto err;
memset(vec[k], 0, pos + 1);
strncpy(vec[k], p, pos);
vlen++;
p = p + pos + 1;
}

/* Print the resulting string vector. */
(void)printf("Initial string = \"%s\"\n", s);
for (k = 0; k < vlen; k++)
(void)printf(" Field %3zd = \"%s\"\n", k, vec[k]);

/* Clean up and exit. */
for (k = 0; k < vsize; k++) {
free(vec[k]);
vec[k] = NULL;
}
free(vec);
vec = NULL;
return EXIT_SUCCESS;

/*
* Clean up and print a warning that some memory allocation has
* failed (this may not work 100% correctly, because fprintf()
* may also fail to work on low-memory conditions :-/
*/
err:
if (vec != NULL) {
for (k = 0; k < vsize; k++) {
free(vec[k]);
vec[k] = NULL;
}
free(vec);
vec = NULL;
}
(void)fprintf(stderr, "Out of memory.\n");
return EXIT_FAILURE;
}
I downloaded the program and ran it on my machine. I got ..

Initial string = "test0//test3/test4//test6"
Field zd = "(null)"
Field zd = ""
Field zd = ""
Field zd = ""
Field zd = ""
Field zd = ""
Field zd = ""

Is this what I should expect? What do you get?

Anyway, a long and complex attempt at a very simple problem.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 16 '06 #12
Pedro Pinto wrote:
Hi there.

I'm trying to do the following.

I have a string, and i want to separate it into other halves.
This is how it should be:

char string[] = "test//test2//test3";

were // is the part were i want to separate it and store on a
bidimensional array like name[50][65],

were 50 diferent names are allowed, each name have 65 bytes of length.

i know how to copy the first bytes until the first //

How can it do to split the string and insert it in name in this onder

name[0] = test
name[1] = test2
name[3] = test3
.......
.......

thanks in advance for any help.

Regards
#include <stdio.h>
#include <stdlib.h>

int main(void) {
int i, c, row = 1, col = 65;
char *n, *p, **names;
/* Limit separator to one '/' character */
char s[] = "test0/test3/test4/test6";
/* Count separators (+1) to n */
p = s;
while ((c = *p++)) {
if (c == '/')
++row;
}
printf("In \"%s\" there are %d rows\n", s, row);
names = malloc(row * sizeof *names);
for (i = 0; i < row; ++i)
names[i] = malloc(col);
/* Replace separators in s with 0 */
p = s;
while (*p) {
if (*p == '/')
*p = 0;
++p;
}
/* Now load up the names array */
p = s;
for (i = 0; i < row; ++i) {
n = names[i];
while ((*n++ = *p++)) ;
}
for (i = 0; i < row; ++i)
printf("%s\n", names[i]);
return 0;
}

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 16 '06 #13
On Wed, 15 Nov 2006 19:42:03 -0500, Joe Wright <jo********@comcast.netwrote:
Giorgos Keramidas wrote:
>I usually prefer strstr() and strcspn() for this sort of thing. When
delimiters are single characters, something like the following works
quite well, IMHO (the strcspn() function can also handle `empty fields',
when consecutive occurences of the separator characters are found):

[snip bogus program]

I downloaded the program and ran it on my machine. I got ..

Initial string = "test0//test3/test4//test6"
Field zd = "(null)"
Field zd = ""
Field zd = ""
Field zd = ""
Field zd = ""
Field zd = ""
Field zd = ""

Is this what I should expect? What do you get?
Right. I had a bug in the initial program. When strcspn() moves past the
end of the last part of the initial string, it returns the position of the
terminating '\0' character. I was blindly moving the `p' pointer with:

p = p + pos + 1;

past the end of the initial string. The bug was easy to find once I turned
on malloc() debugging in FreeBSD, so the fixed program is now (modified
lines marked with '#' at their beginning):

| #include <stdio.h>
| #include <stdlib.h>
| #include <string.h>
|
| static const char *s = "test0//test3/test4//test6";
| static const char *sep = "/";
|
| int
| main(void)
| {
| char **vec, **tmp;
| size_t vsize, vlen;
| const char *p;
| size_t j, k, pos;
|
| /*
| * Allocate some initial space for vec[], which we'll grow
| * afterwards as necessary.
| */
| vsize = 1;
| vec = malloc(vsize * sizeof *vec);
| if (vec == NULL)
| goto err;
#| memset(vec, 0, (vsize * sizeof *vec));
|
| /*
| * Split the string from `s' to a newly allocated vector of
| * strings, stored in vec[]. The allocated size of vec[] is
| * kept in `vsize' and the in-use part of vec[] is vec[0]
| * ... vec[vlen-1] (a total of `vlen' elements).
| */
| for (p = s, k = vlen = 0; p != NULL && *p != 0; k++) {
| /* Find the position of the next separator. */
| pos = strcspn(p, sep);
|
| /*
| * Make sure vec[] can fit another element.
| */
| if (k >= vsize) {
| tmp = realloc(vec, (2 * vsize) * sizeof *vec);
| if (tmp == NULL)
| goto err;
| vec = tmp;
| vsize *= 2;
| for (j = vlen; j < vsize; j++)
| vec[j] = NULL;
| }
| vec[k] = malloc((pos + 1) * sizeof(char));
| if (vec[k] == NULL)
| goto err;
| memset(vec[k], 0, pos + 1);
| strncpy(vec[k], p, pos);
| vlen++;
#| p = p + pos;
#| if (*p != '\0')
#| p++;
| }
|
| /* Print the resulting string vector. */
| (void)printf("Initial string = \"%s\"\n", s);
| for (k = 0; k < vlen; k++)
| (void)printf(" Field %3zd = \"%s\"\n", k, vec[k]);
|
| /* Clean up and exit. */
| for (k = 0; k < vsize; k++) {
| free(vec[k]);
| vec[k] = NULL;
| }
| free(vec);
| vec = NULL;
| return EXIT_SUCCESS;
|
| /*
| * Clean up and print a warning that some memory allocation
| * has failed (this may not work 100% correctly, because
| * fprintf() may also fail to work on low-memory conditions :-/
| */
| err:
| if (vec != NULL) {
| for (k = 0; k < vsize; k++) {
| free(vec[k]);
| vec[k] = NULL;
| }
| free(vec);
| vec = NULL;
| }
| (void)fprintf(stderr, "Out of memory.\n");
| return EXIT_FAILURE;
| }
Anyway, a long and complex attempt at a very simple problem.
This is something I am frequently accused of. Then again, I like
covering as many edge cases as possible, as early as possible :)

If you actually remove all the house-keeping around malloc() and the parts
which make sure that there is an adequately sized vec[] array of pointers
to the string-parts, then this is (IMHO) a very `simple' wrapper around
strcspn() and strncpy().
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Heh! Nice signature :)

Nov 18 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andi B | last post by:
If I have an array set up like so to contain a small code, and the name of the person to whom the code relates, the values split by a comma: DMCName="1SC,Andrea Pidgeon" and I want to be able...
3
by: Rakesh | last post by:
Hi, I was 'googling' to look out for some ways of optimizing the code and came across this term - 'hot / cold splitting'. In short, the discussion is about splitting heavily accessed ( hot )...
11
by: Steve Darby | last post by:
Can anyone help with this problem. I am attempting to dynamically draw a graph using data from a cookie. I have written the script to actually draw the graph, for which I hav created two arrays...
13
by: James Conrad St.John Foreman | last post by:
One of the larger tables in our database is now 6.8 million rows (1 per financial transaction since 2000). Every time an amendment is made to a booking, new rows are added to the table for each...
4
by: r035198x | last post by:
Breaking up a string Instead of using the old StringTokenizer class, a simple trick is to use the String.split method. String string = "This is a string"; String tokens = string.split("...
2
by: shadow_ | last post by:
Hi i m new at C and trying to write a parser and a string class. Basicly program will read data from file and splits it into lines then lines to words. i used strtok function for splitting data to...
4
by: techusky | last post by:
I am making a website for a newspaper, and I am having difficulty figuring out how to take a string (the body of an article) and break it up into three new strings so that I can display them in the...
3
by: Alexander Adam | last post by:
Hi! I've got an input wchar_t array in a callback function from expat: void my_callback(const wchar_t* data); Additionally, I got a second function that I need to call within my callback...
14
by: spreadbetting | last post by:
I'm trying to split a string into an separate arrays but the data is only delimited by a comma. The actual data is one long string but the info is in a regular format and repeats after every five...
2
by: pereges | last post by:
I've an array : {100,20, -45 -345, -2 120, 64, 99, 20, 15, 0, 1, 25} I want to split it into two different arrays such that every number <= 50 goes into left array and every number 50 goes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.