Hi,
I'm trying to write a function that concats a string onto the end of the previous.
So, if I first pass it ABC
the buffer string becomes "ABC"
then I pass it DEF
and the buffer string becomes "ABCDEF"
Any suggestions?
Thanks
Hi,
I'm trying to write a function that concats a string onto the end of the previous.
So, if I first pass it ABC
the buffer string becomes "ABC"
then I pass it DEF
and the buffer string becomes "ABCDEF"
Any suggestions?
Thanks
Start writing the code and post it here if and when you have any questions or issues.
Mainframe assembler programmer by trade. C coder when I can.
You'll need a static thing that keeps track of the string-so-far. Are you allowed to use what's in string.h? Otherwise you'll have to rewrite strcat here too.
I can use string.h
strcat is good...
but how do i dynamically allocate for this?
Do you need to dynamically allocate? Is char the_answer[256] (or whatever) not going to work?
If you need to dynamically allocate, then you need two static things -- a pointer and a size, and you would use realloc to add the new size to the old size and go from there.
I'm getting the warning: "passing argument 2 of 'strcat' from incompatible pointer type"
I'm getting my element from a file...
fread(&element, 3, 1, input);
and concatting with:
strcat (buffer, &element);
Is this wrong?
please help
Can you post more of the code snippet you are using for the string catenation.
Last edited by itCbitC; 11-10-2008 at 02:45 PM.