Often, when I write some C code, I write header file at last. One task that is really long and boring is to copy function prototype into header. To help me with this task, I wrote a command line to extract the function prototype and copy them directly in the header file.
Here is the command:
1 |
cat *.c | grep -E "^\w" | sed 's/$/;/' |
You can forward the output to a file using a Unix redirection like this:
1 |
cat *.c | grep -E "^\w" | sed 's/$/;/' >> header.h |
Don’t forget to add the usual #ifndef in order to protect from double inclusion.
Leave a Reply