For the implicit-declaration thing, you use do_buffer() in main() before you declare it. This is bad. Use a function prototype, like this:
Code:
char* do_buffer(FILE*);
The same should be done for your other functions. Place them in your global declarations, before main().
By the way, why is source declared globally, when you are passing it as a parameter? Generally, it is considered better to pass variables as parameters than to define global ones. Same thing with the char c. Although it isn't used as a parameter, you'll have to be very careful to avoid accidentally clobbering c by a calling a function which also uses c. A warning:
c is being used uninitialized in print_output() when first called from main().
As far as declaring buffer as global to solve the returning-address-of-local-variable problem in do_buffer(), the usual way of doing this is to avoid global variables and pass a char* as a parameter to do_buffer(), and declare the buffer itself in the routine that calls do_buffer()... that is, declare char buffer[80] in print_output(), and pass it as a parameter to do_buffer(). If you do it this way, you'll have to add a char* parameter to both the function definition and the prototype.
Quote:
NULL is an integer value, while b is an array of type char. Replace NULL with '\0' (backslash zero), which is a char.
|
Sort of. NULL has the type of void*. Assigning a pointer type to any integer type always gives a warning. Using 0 or '\0' will solve this problem.