I have a simple program with a couple of functions. I need the program to return a buffer that is being built in the functions and in the main function. I decided to do so with a global buffer. Supposing I know the maximum size of the final string, what is the best way to do so - creating the buffer, appending the strings and returning it? the program looks somewhat like this:
// Declaring the global buffer
int funcB()
{
// Append string to buffer
}
int funcA()
{
// Append string to buffer from funcA
return
}
main()
{
// Append string to buffer from main
funcA()
// Append string to buffer from main
funcB()
// Append string to buffer from main
// Return the buffer
}
each comment is not a comment on the code, it's the action that the program need to do.
Thank you!
Aucun commentaire:
Enregistrer un commentaire