Writing a character to the stream is ensured by several functions in C, such as :
int fputc ( int character, FILE * stream );
int putchar ( int character );
int putc ( int character, FILE * stream );
...
My question is simple : is there any function which provide the possibility to write a character into a char*? (callback(int character, char * stream))
update
:to explain more my problem
i’am using lex/yacc compiling solution.
input() funcion returns the next character in the stream .I want to store for a specified condition the whole stream returned by this function into a variable.
Since pointer arithmetic is in the very nature of C, there are no such functions. To put a character into some memory pointed to by
streamand advance it, you would do:At the next sequence point
streamwill be pointing to the new, still unwritten character.Of course, make sure that you don’t advance
streambeyond the bounds of its allocated area. To prevent this from happening you could do a simple calculation:basewould be a pointer to the beginning of the allocated area, the initial value ofstream.