473,396 Members | 1,996 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,396 software developers and data experts.

Is there an easier way to work with pointers (sample code included)

Is there an easier way to code the cmp procedure without going thru all
the pointer manipulations?

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

int cmp(const void *i, const void *j)
{
void *p1, *p2;
char **s1, **s2;
p1=(void *) i;
p2=(void *) j;
s1=(void *) p1;
s2=(void *) p2;
return strcmp(*s1,*s2);
}

int main(void)
{
char string0[]="zebra";
char string1[]="hello";
char string2[]="goodbye";

char *base[3];

base[0]=(char *)string0;
base[1]=(char *)string1;
base[2]=(char *)string2;

printf("\nbase[0] %s",base[0]);
printf("\nbase[1] %s",base[1]);
printf("\nbase[2] %s\n",base[2]);

qsort(&base,3,sizeof(base[0]),(void *)cmp);

printf("\nbase[0] %s",base[0]);
printf("\nbase[1] %s",base[1]);
printf("\nbase[2] %s\n",base[2]);
}
TIA,

Walter

Mar 8 '06 #1
22 1925
On 8 Mar 2006 10:22:53 -0800, wa***************@gmail.com wrote:
Is there an easier way to code the cmp procedure without going thru all
the pointer manipulations?

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

int cmp(const void *i, const void *j)
{
void *p1, *p2;
char **s1, **s2;
p1=(void *) i;
p2=(void *) j;
s1=(void *) p1;
s2=(void *) p2;
return strcmp(*s1,*s2);
}


int cmp(const void *i, const void *j)
{
char *s1 = i;
char *s2 = p;

return strcmp(s1, s2);
}
Is that what you're trying to do?

BTW, please properly indent code you post. Your compiler may not care,
but people reading it do.

--
Al Balmer
Sun City, AZ
Mar 8 '06 #2
wa***************@gmail.com wrote:
Is there an easier way to code the cmp procedure without going thru all
the pointer manipulations?
In addition to an excessive number of useless casts, you have left out a
key header.
Yes, you are trying too hard. Compare the code below to your code,
which follows it:

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

int compare_strings(const void *i, const void *j)
{
return strcmp(*(char **) i, *(char **) j);
}

void showstrs(size_t n, char *s[n])
{
size_t i;
for (i = 0; i < n; i++)
printf("s[%u] %s\n", (unsigned) i, s[i]);
}

int main(void)
{
char *base[] = { "zebra", "hello", "goodbye" };
size_t n = sizeof base / sizeof *base;
showstrs(n, base);
putchar('\n');
qsort(base, n, sizeof *base, compare_strings);
showstrs(n, base);
return 0;
}

[output]
s[0] zebra
s[1] hello
s[2] goodbye

s[0] goodbye
s[1] hello
s[2] zebra
[OP's code]
#include <stdlib.h>
#include <string.h>

int cmp(const void *i, const void *j)
{
void *p1, *p2;
char **s1, **s2;
p1=(void *) i;
p2=(void *) j;
s1=(void *) p1;
s2=(void *) p2;
return strcmp(*s1,*s2);
}

int main(void)
{
char string0[]="zebra";
char string1[]="hello";
char string2[]="goodbye";

char *base[3];

base[0]=(char *)string0;
base[1]=(char *)string1;
base[2]=(char *)string2;

printf("\nbase[0] %s",base[0]);
printf("\nbase[1] %s",base[1]);
printf("\nbase[2] %s\n",base[2]);

qsort(&base,3,sizeof(base[0]),(void *)cmp);

printf("\nbase[0] %s",base[0]);
printf("\nbase[1] %s",base[1]);
printf("\nbase[2] %s\n",base[2]);
}
TIA,

^^^
Are you a bill-collector or a script-kiddie?

Mar 8 '06 #3
In article <11**********************@z34g2000cwc.googlegroups .com>,
<wa***************@gmail.com> wrote:
Is there an easier way to code the cmp procedure without going thru all
the pointer manipulations?

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

int cmp(const void *i, const void *j)
{
void *p1, *p2;
char **s1, **s2;
p1=(void *) i;
p2=(void *) j;
s1=(void *) p1;
s2=(void *) p2;
return strcmp(*s1,*s2);
}

[... the rest of the code snipped ...]

As a rule, the use of casts in a code is an indication that
something is wrong. There are exceptions to this rule, but in
general a cast should raise a red flag in your mind. Here is
a modified version of your code without casts. It is shorte
and should be easier to understand and debug:

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

int cmp(const void *a, const void *b)
{
char * const *aa = a;
char * const *bb = b;
return strcmp(*aa, *bb);
}

int main(void)
{
char string0[] = "zebra";
char string1[] = "hello";
char string2[] = "goodbye";
char *base[3];

base[0] = string0;
base[1] = string1;
base[2] = string2;

qsort(base, (sizeof base)/(sizeof base[0]), sizeof base[0], cmp);

printf("base[0] = %s\n",base[0]);
printf("base[1] = %s\n",base[1]);
printf("base[2] = %s\n",base[2]);

return EXIT_SUCCESS;
}

--
Rouben Rostamian
Mar 8 '06 #4
Al Balmer wrote:
[...qsort compare function on string array...]
int cmp(const void *i, const void *j)
{
char *s1 = i;
char *s2 = p;

return strcmp(s1, s2);
}

[...]

Any reason you can't simply do:

int cmp(const void *i, const void *j)
{
return strcmp(i,j);
}

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Mar 8 '06 #5
Al Balmer wrote:
On 8 Mar 2006 10:22:53 -0800, wa***************@gmail.com wrote:
Is there an easier way to code the cmp procedure without going thru all
the pointer manipulations?

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

int cmp(const void *i, const void *j)
{
void *p1, *p2;
char **s1, **s2;
p1=(void *) i;
p2=(void *) j;
s1=(void *) p1;
s2=(void *) p2;
return strcmp(*s1,*s2);
}
int cmp(const void *i, const void *j)
{
char *s1 = i;
char *s2 = p;


Don't you mean:
const char *s1 = i;
const char *s2 = j;
return strcmp(s1, s2);
}
Is that what you're trying to do?

BTW, please properly indent code you post. Your compiler may not care,
but people reading it do.


Definitely.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Mar 8 '06 #6

<wa***************@gmail.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
Is there an easier way to code the cmp procedure without going thru all
the pointer manipulations?

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

int cmp(const void *i, const void *j)
{
void *p1, *p2;
char **s1, **s2;
p1=(void *) i;
p2=(void *) j;
s1=(void *) p1;
s2=(void *) p2;
return strcmp(*s1,*s2);
}

int main(void)
{
char string0[]="zebra";
char string1[]="hello";
char string2[]="goodbye";

char *base[3];

base[0]=(char *)string0;
base[1]=(char *)string1;
base[2]=(char *)string2;

printf("\nbase[0] %s",base[0]);
printf("\nbase[1] %s",base[1]);
printf("\nbase[2] %s\n",base[2]);

qsort(&base,3,sizeof(base[0]),(void *)cmp);

printf("\nbase[0] %s",base[0]);
printf("\nbase[1] %s",base[1]);
printf("\nbase[2] %s\n",base[2]);
}
TIA,

Walter


Sorting a plain array of strings is usually pretty pointless.
Do something like this

typedef struct
{
char name[64];
char *description;
/* probably lots of other data associated with animals here */
} ANIMAL;

int cmp(const void *e1, const void *e2)
{
const ANIMAL *a1 = e1;
const ANIMAL *a2 = e2;

return strcmp(al->name, a2->name);
}

That's not too burdensome.
--
Buy my book 12 Common Atheist Arguments (refuted)
$1.25 download or $6.90 paper, available www.lulu.com
Mar 8 '06 #7
wa***************@gmail.com wrote:
Is there an easier way to code the cmp procedure without going thru
all the pointer manipulations?

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

int cmp(const void *i, const void *j)
{
void *p1, *p2;
char **s1, **s2;
p1=(void *) i;
p2=(void *) j;
s1=(void *) p1;
s2=(void *) p2;
return strcmp(*s1,*s2);
}

In addition to what all the others have said, you should almost NEVER
cast away const from a pointer. That's a major indicator that there's a
design flaw.

Brian
Mar 8 '06 #8
"Default User" <de***********@yahoo.com> writes:
wa***************@gmail.com wrote:
Is there an easier way to code the cmp procedure without going thru
all the pointer manipulations?

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

int cmp(const void *i, const void *j)
{
void *p1, *p2;
char **s1, **s2;
p1=(void *) i;
p2=(void *) j;
s1=(void *) p1;
s2=(void *) p2;
return strcmp(*s1,*s2);
}

In addition to what all the others have said, you should almost NEVER
cast away const from a pointer. That's a major indicator that there's a
design flaw.


The exception would be when you're implementing something like
strchr(); where you want your parameter list to indicate a guarantee
that you won't change the string, but you don't want to force the
caller to make that same guarantee (or do the cast there).
Mar 8 '06 #9
wa***************@gmail.com, le 08/03/2006 a écrit :
Is there an easier way to code the cmp procedure without going thru all
the pointer manipulations?


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

#define AFFICHE printf("\nbase[0] %s""\nbase[1] %s""\nbase[2] %s\n",\
base[0],\
base[1],\
base[2])

typedef char* chaine;
typedef int(*f_comp_t)(const void*, const void*);
int cmp_chaine(const chaine* i, const chaine* j)
{
return strcmp(*i,*j);
}

int main(void)
{
char string0[]="zebra", string1[]="hello", string2[]="goodbye";
chaine base[] = {string0, string1, string2};
AFFICHE;
qsort(base,3,sizeof(chaine),(f_comp_t)cmp_chaine);
AFFICHE;
return 0;
}

Or:

/* .... */

int main(void)
{
char string0[]="zebra", string1[]="hello", string2[]="goodbye";
chaine base[] = {string0, string1, string2};
f_comp_t cmp = (f_comp_t)cmp_chaine;
AFFICHE;
qsort(base,3,sizeof(chaine),cmp);
AFFICHE;
return 0;
}

--
Pierre Maurette
Mar 9 '06 #10
On Wed, 08 Mar 2006 19:28:13 +0000, Flash Gordon
<sp**@flash-gordon.me.uk> wrote:
Al Balmer wrote:
On 8 Mar 2006 10:22:53 -0800, wa***************@gmail.com wrote:
Is there an easier way to code the cmp procedure without going thru all
the pointer manipulations?

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

int cmp(const void *i, const void *j)
{
void *p1, *p2;
char **s1, **s2;
p1=(void *) i;
p2=(void *) j;
s1=(void *) p1;
s2=(void *) p2;
return strcmp(*s1,*s2);
}


int cmp(const void *i, const void *j)
{
char *s1 = i;
char *s2 = p;


Don't you mean:
const char *s1 = i;
const char *s2 = j;

Yup. <g> You can tell how often I use const. The compiler would have
reminded me.
return strcmp(s1, s2);
}
Is that what you're trying to do?

BTW, please properly indent code you post. Your compiler may not care,
but people reading it do.


Definitely.


--
Al Balmer
Sun City, AZ
Mar 9 '06 #11
Micah Cowan wrote:
"Default User" <de***********@yahoo.com> writes:

In addition to what all the others have said, you should almost
NEVER cast away const from a pointer. That's a major indicator that
there's a design flaw.


The exception would be when you're implementing something like
strchr(); where you want your parameter list to indicate a guarantee
that you won't change the string, but you don't want to force the
caller to make that same guarantee (or do the cast there).


I guess I'm not following. You can always pass a non-const pointer
through a const parameter. The caller wouldn't need to cast, nor would
the implementer.

In the previous code, the OP had const parameters and then blithely
cast the const away inside the function.

Brian
Mar 9 '06 #12
Default User said:
Micah Cowan wrote:
"Default User" <de***********@yahoo.com> writes:
> In addition to what all the others have said, you should almost
> NEVER cast away const from a pointer. That's a major indicator that
> there's a design flaw.


The exception would be when you're implementing something like
strchr(); where you want your parameter list to indicate a guarantee
that you won't change the string, but you don't want to force the
caller to make that same guarantee (or do the cast there).


I guess I'm not following. You can always pass a non-const pointer
through a const parameter. The caller wouldn't need to cast, nor would
the implementer.


No, think about strchr for a second (and don't worry too much about whether
I've got the implementation right - focus on the types):

char *strchr(const char *s, int ch)
{
char *p = (char *)s; /* either you cast it here... */
while(*p != '\0' && *p != ch)
{
++p;
}
if(*p == '\0')
{
p = NULL;
}
return p;
}

char *strchr(const char *s, int ch)
{
while(*s != '\0' && *s != ch)
{
++s;
}
if(*s == '\0')
{
s = NULL;
}
return (char *)s; /*... or you cast it here */
}
In the previous code, the OP had const parameters and then blithely
cast the const away inside the function.


Sure, and your point was perfectly valid. I think we're moving on a bit from
there now.
--
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)
Mar 9 '06 #13
wa***************@gmail.com wrote:

Is there an easier way to code the cmp procedure without going thru all
the pointer manipulations?

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

int cmp(const void *i, const void *j)
{
void *p1, *p2;
char **s1, **s2;
p1=(void *) i;
p2=(void *) j;
s1=(void *) p1;
s2=(void *) p2;
return strcmp(*s1,*s2);
}

int main(void)
{
char string0[]="zebra";
char string1[]="hello";
char string2[]="goodbye";

char *base[3];

base[0]=(char *)string0;
base[1]=(char *)string1;
base[2]=(char *)string2;

printf("\nbase[0] %s",base[0]);
printf("\nbase[1] %s",base[1]);
printf("\nbase[2] %s\n",base[2]);

qsort(&base,3,sizeof(base[0]),(void *)cmp);

printf("\nbase[0] %s",base[0]);
printf("\nbase[1] %s",base[1]);
printf("\nbase[2] %s\n",base[2]);
}


/* BEGIN new.c */

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

int cmp(const void *i, const void *j)
{
return strcmp(i, j);
}

int main(void)
{
char string0[] = "zebra";
char string1[] = "hello";
char string2[] = "goodbye";
char *base[3];

base[0] = string0;
base[1] = string1;
base[2] = string2;
printf("base[0] %s\n", base[0]);
printf("base[1] %s\n", base[1]);
printf("base[2] %s\n", base[2]);
putchar('\n');
qsort(base, sizeof base / sizeof*base, sizeof*base, cmp);
printf("base[0] %s\n",base[0]);
printf("base[1] %s\n",base[1]);
printf("base[2] %s\n",base[2]);
return 0;
}

/* END new.c */
--
pete
Mar 9 '06 #14
wa***************@gmail.com wrote:
Is there an easier way to code the cmp procedure without going thru all
the pointer manipulations?

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

int cmp(const void *i, const void *j)
{
void *p1, *p2;
char **s1, **s2;
p1=(void *) i;
p2=(void *) j;
s1=(void *) p1;
s2=(void *) p2;
return strcmp(*s1,*s2);
}

int main(void)
{
char string0[]="zebra";
char string1[]="hello";
char string2[]="goodbye";

char *base[3];

base[0]=(char *)string0;
base[1]=(char *)string1;
base[2]=(char *)string2;

printf("\nbase[0] %s",base[0]);
printf("\nbase[1] %s",base[1]);
printf("\nbase[2] %s\n",base[2]);

qsort(&base,3,sizeof(base[0]),(void *)cmp);

printf("\nbase[0] %s",base[0]);
printf("\nbase[1] %s",base[1]);
printf("\nbase[2] %s\n",base[2]);
}


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

#define COUNT 3
#define MAX_LEN 32

char strings[COUNT][MAX_LEN] = {"zebra", "hello", "goodbye"};

void show(char strings[][MAX_LEN])
{
int k;

for (k = 0; k < COUNT; k++) printf("%s, ", strings[k]);
printf("\n");
}
int main(void)
{
show(strings);
qsort(strings, COUNT, MAX_LEN,
(int (*)(const void *, const void *)) strncmp);
show(strings);
return 0;
}
August

--
I am the "ILOVEGNU" signature virus. Just copy me to your
signature. This email was infected under the terms of the GNU
General Public License.
Mar 9 '06 #15
pete wrote:

/* BEGIN new.c */

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

int cmp(const void *i, const void *j)
{
return strcmp(i, j);
}

int main(void)
{
char string0[] = "zebra";
char string1[] = "hello";
char string2[] = "goodbye";
char *base[3];

base[0] = string0;
base[1] = string1;
base[2] = string2;
printf("base[0] %s\n", base[0]);
printf("base[1] %s\n", base[1]);
printf("base[2] %s\n", base[2]);
putchar('\n');
qsort(base, sizeof base / sizeof*base, sizeof*base, cmp);
printf("base[0] %s\n",base[0]);
printf("base[1] %s\n",base[1]);
printf("base[2] %s\n",base[2]);
return 0;
}

/* END new.c */


One thing that AFAIK hasn't been pointed out in the thread is there is
no language guarantee that this will sort the strings into the order:

goodbye
hello
zebra

--
Peter

Mar 9 '06 #16
Richard Heathfield wrote:
Default User said:
I guess I'm not following. You can always pass a non-const pointer
through a const parameter. The caller wouldn't need to cast, nor
would the implementer.

return (char *)s; /*... or you cast it here */


Bah, I didn't think it through to the return. Never mind.


Brian
Mar 9 '06 #17
"Richard Heathfield" <in*****@invalid.invalid> wrote
No, think about strchr for a second (and don't worry too much about
whether
I've got the implementation right - focus on the types):

char *strchr(const char *s, int ch)

This is where the hacked in status of const as a late addition to the
language beocmes apparent.
const should taint everything it points to, and all pointers derived from
it. But that would be a major reengineering exercise.
--
Buy my book 12 Common Atheist Arguments (refuted)
$1.25 download or $6.90 paper, available www.lulu.com
Mar 9 '06 #18
On 2006-03-09, Malcolm <re*******@btinternet.com> wrote:
"Richard Heathfield" <in*****@invalid.invalid> wrote
No, think about strchr for a second (and don't worry too much about
whether
I've got the implementation right - focus on the types):

char *strchr(const char *s, int ch)

This is where the hacked in status of const as a late addition to the
language beocmes apparent.
const should taint everything it points to, and all pointers derived from
it. But that would be a major reengineering exercise.


typeof would allow this, after a fashion:

#define strchr(x,c) (typeof x)strchr(x,c)
Mar 9 '06 #19
On 2006-03-09, pete <pf*****@mindspring.com> wrote:
[...]
int cmp(const void *i, const void *j)
{
return strcmp(i, j);
}

[...]
char *base[3];
base[0] = string0;
base[1] = string1;
base[2] = string2;
[...]
qsort(base, sizeof base / sizeof*base, sizeof*base, cmp);


Several people have posted code like this now, all apparently without
noticing that it's wrong.

base is an array of pointers to char. This is passed to qsort. qsort
calls cmp with two pointers, each of which points *to an element of
the array*.

Those void *'s in the argument of cmp are "really" char **, not char *,
and passing them to strcmp produces undefined behavior.

It so happens that you (and the OP) have laid out the program so that
on most platforms strcmp will reach a zero byte somewhere before
faulting, and the conventional layout of automatic storage is such
that strcmp interpreting the addresses as strings will generate the
expected output sort order, so just running the program once to check
it is misleading.

cmp needs to be

int cmp(const void *i0, const void *j0) {
const char *const *i = i0;
const char *const *j = j0;
return strcmp(*i, *j);
}

HTH.

--
- David A. Holland
(the above address works if unscrambled but isn't checked often)
Mar 9 '06 #20
David Holland wrote:

On 2006-03-09, pete <pf*****@mindspring.com> wrote:
> [...]
> int cmp(const void *i, const void *j)
> {
> return strcmp(i, j);
> }
>
> [...]
> char *base[3];
> base[0] = string0;
> base[1] = string1;
> base[2] = string2;
> [...]
> qsort(base, sizeof base / sizeof*base, sizeof*base, cmp);
Several people have posted code like this now, all apparently without
noticing that it's wrong.

base is an array of pointers to char. This is passed to qsort. qsort
calls cmp with two pointers, each of which points *to an element of
the array*.

Those void *'s in the argument of cmp are "really" char **,
not char *,
and passing them to strcmp produces undefined behavior.

It so happens that you (and the OP) have laid out the program so that
on most platforms strcmp will reach a zero byte somewhere before
faulting, and the conventional layout of automatic storage is such
that strcmp interpreting the addresses as strings will generate the
expected output sort order, so just running the program once to check
it is misleading.


I hate when that happens!
cmp needs to be

int cmp(const void *i0, const void *j0) {
const char *const *i = i0;
const char *const *j = j0;
return strcmp(*i, *j);
}

HTH.


Oops!
Good catch!

--
pete
Mar 9 '06 #21
Groovy hepcat Al Balmer was jivin' on Wed, 08 Mar 2006 12:00:35 -0700
in comp.lang.c.
Re: Is there an easier way to work with pointers (sample code
included)'s a cool scene! Dig it!
On 8 Mar 2006 10:22:53 -0800, wa***************@gmail.com wrote:
Is there an easier way to code the cmp procedure without going thru all
the pointer manipulations?

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

int cmp(const void *i, const void *j)
{
void *p1, *p2;
char **s1, **s2;
p1=(void *) i;
p2=(void *) j;
s1=(void *) p1;
s2=(void *) p2;
return strcmp(*s1,*s2);
}


int cmp(const void *i, const void *j)
{
char *s1 = i;
char *s2 = p;

return strcmp(s1, s2);
}


That won't do. The OP is dereferncing the pointers (s1 and s2). They
have type char **, not char *.
Also, you're discarding the const qualifier in the assignment.
That's not kosher without a cast.

----------------------------------------------------------------------
6.5.16.1 Simple assignment

Constraints
....
— one operand is a pointer to an object or incomplete type and the
other is a pointer to a qualified or unqualified version of void, and
the type pointed to by the left has all the qualifiers of the type
pointed to by the right;
----------------------------------------------------------------------

The type pointed to by the left operands (unqualified *s1, *s2) don't
have all the qualifiers of that pointed to by the right (const
qualified *i, *j).
And the strings being sorted or searched (I'm assuming this is a
comparison function a pointer to which is to be passed to bsearch() or
qsort() function) should really be treated as const qualified (ie.,
should *be* const qualified).
So, something like this would be in order:

#include <string.h>

int cmp(const void *i, const void *j)
{
const char *const *s1 = i;
const char *const *s2 = j;

return strcmp(*s1, *s2);
}

--

Dig the even newer still, yet more improved, sig!

http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
Mar 12 '06 #22
On Sun, 12 Mar 2006 02:37:50 GMT, ph******@alphalink.com.au.NO.SPAM
(Peter "Shaggy" Haywood) wrote:

int cmp(const void *i, const void *j)
{
char *s1 = i;
char *s2 = p;

return strcmp(s1, s2);
}
That won't do. The OP is dereferncing the pointers (s1 and s2). They
have type char **, not char *.


That why I asked (you snipped) "Is that what you're trying to do?" The
OP's code indicated to me that he was rather confused. I picked
something I thought was more likely than what he actually wrote.
Also, you're discarding the const qualifier in the assignment.
That's not kosher without a cast.


Yes. Pointed out and acknowledged three days ago, in my very next
message.

--
Al Balmer
Sun City, AZ
Mar 12 '06 #23

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

Similar topics

73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
13
by: cjl | last post by:
Hey all: I'm working on a 'pure' python port of some existing software. Implementations of what I'm trying to accomplish are available (open source) in C++ and in Java. Which would be...
0
by: ReaprZero | last post by:
Hi, I'm using Cygwin and ActiveState perl to try to compile a sample application using SWIG. I'm using the short tutorial from http://www.swig.org/tutorial.html (the perl part of it), but with a...
37
by: Harsimran | last post by:
Can any one explain what are far pointers and what is the difference between malloc and calloc .Which is better ?
7
by: _BNC | last post by:
Another thread mentioned non-Pinned pointers as a possible reason for an Interop bug. I'd like to find out more about how this comes about. I presume that the Garbage Collector makes a sweep,...
13
by: dm1608 | last post by:
I know all the hype right now from Microsoft is how much easier, faster, and less code ASP.NET 2.0 provides over previous versions. I'm puzzled by this as I could turn out an classic ASP webpage...
3
by: lucky1020 | last post by:
hi friends, i am new to this can any one help me regarding this issue my aim is to Write a program which computes the largest palindrome substring of a string using pointers Input: The input is...
7
by: phil_w | last post by:
To practice some C I have been looking at the Burrows-Wheeler Transform. Ive got a small program that builds the initial table of possible combinations of the original string, used to find the...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.