the only arg to a class is a string :
Are you sure that you have the right newsgroup? The C language does
not have a 'class'.
internally i redefine this input var sometime, not always.
if it's redefine i get something like that :
/Users/yvon/Desktop/raliasrecord-0.0.1 <= input
/Users/yvon/work/Ruby/Native/raliasrec <= output
where the output should be :
/Users/yvon/work/Ruby/Native/raliasrecord-0.0.1
this string being passed by a pointer, how do i reallocate memory for it
If what is being passed in is a literal string, and you want to
change it "in place", then you cannot portably do that in C, as C
explicitly permits literal strings to be stored in read-only memory.
You could, however, construct a new string and return a pointer to it.
If what is being passed in is the pointer to an array of char
that is a local or global variable, then there is no way for you
to extend it "in place": the best you can do in such a case is
return a pointer to the new string.
If what is being passed in is a pointer to a malloc()'d block of
memory, then you can use realloc() to get a bigger storage area.
However, when you use realloc(), if it does not happen to have
enough room to extend the memory where it happens to sit, then
realloc() will find another chunk of memory somewhere that is
big enough for the new size, and will copy the contents of the
current chunk over there, and will destroy the old chunk of
memory and will return a pointer to the new location. If
realloc() just -happened- to be able to fit the bigger string
"in place" then you are okay, but if realloc() had to move the chunk
then you have a problem, in that the calling routine knows only
the old address for the chunk before it was moved -- and there is
no mechanism in C to alter a passed-in pointer and have the change
noticed in the levels above. Thus again you need to return a pointer
to the new string.
Alternately, if what gets passed to you is not the pointer to the
string, but is instead a pointer *to* the pointer to the string,
then you can return the new pointer value through that.
For example,
#include <stdio.h>
void newstring( char **oldstringptr ) {
*oldstringptr = "Bye!";
}
int main(void) {
char *avariable = "Hello!";
puts(avariable);
newstring(&avariable);
puts(avariable);
return 0;
}