Farzin Ashraghi wrote in message <[EMAIL PROTECTED]>...
>
>Hi!
>
>I'm trying to delete a "char" variable using:
>StrCopy(charP, "");
>where charP is the pointer to that char, but it doesn't work.
>
>Could you help me please,
Could you be a little more clear about what you are trying
to accomplish?
If charP points to the beginning of a string, and you want
to clear the contents of that string, what you've got should
work.
char sz[15] = "Hello, world.";
char *p = &sz[0];
StrCopy(p, "");
the contents of sz would be: '\0', 'e', 'l', 'l', ...
Since a string ends w/ a nul byte, this effectively clears
the string.
if charP points somewhere in the middle of a string, what
you will be doing is truncating the string to that point.
char *p = &sz[3];
StrCopy(p, "");
the contents of sz would be: 'H', 'e', 'l', '\0', 'o' ... effectively
truncating the string to "Hel".
If what you want is actually to -delete- the third character,
resulting in a string looking like "Helo, world." then you need
to move all the chars after that char down.
StrCopy(&sz[3], &sz[4]);
(note: I don't know if StrCopy is safe when copying overlapping
memory ranges, but I -think- that it is).
--
-Richard M. Hartman
[EMAIL PROTECTED]
186,000 mi/sec: not just a good idea, it's the LAW!
--
For information on using the ACCESS Developer Forums, or to unsubscribe, please
see http://www.access-company.com/developers/forums/