这是主函数文件 main.c
#include <stdio.h>
#include "creaters.h"

int main ()
{
int choice;

printf( "Witch Coder do you want:\n"
"1.Header_Coder\n"
"2.Menu_Coder\n" );

scanf( "%d", &choice );
getchar();
if ( choice < 1 || choice > 2 ) {
fprintf( stderr, "ERROR CHOICE!\n" );
return 0;
}

switch ( choice ) {
case 1:Header_Coder();
break;
case 2:Menu_Coder();
break;
default:fprintf( stderr, "ERROR: Coder's switch stament has an unknown error!\n" );
}

return 0;
}
这是头文件生成函数文件 H_Coder.c
偷懒了,必须在函数定义前加标记才行。不过有兴趣的同学可以自己根据需要修改。
#include <stdio.h>
#include <string.h>

#define BUFF_SIZE 200
#define NAME_SIZE 100

void Header_Coder ()
{
int i;
char buff[BUFF_SIZE], file_name[NAME_SIZE];
FILE *pa = NULL, *pb = NULL;

printf( "SOURCE FILE NAME:" );
scanf( "%s", file_name );
pa = fopen( file_name, "r" );
if ( pa == NULL ) {
fprintf( stderr, "ERROR: FILE %s HAVEN'T OPEN!\n ", file_name );
return;
}

printf( "HEADER FILE NAME:" );
scanf( "%s", file_name );
pb = fopen( file_name, "w" );
if ( pb == NULL ) {
fprintf( stderr, "ERROR: FILE %s HAVEN'T OPEN!\n ", file_name );
}

while ( fgets( buff, 199, pa ) ) {
if ( !strncmp( buff, "/*FUNCTION*/", 12 ) ) {
fgets( buff, 199, pa );
for ( i = 0; buff[i] != '\n'; i++ )
;
buff[ i++ ] = ';';
buff[ i++ ] = '\n';
buff[i] = '\0';
fprintf( pb, "%s", buff );
}
}

printf( "WORK DONE!\n" );
fclose( pa );
fclose( pb );
}
这是目录菜单生成函数文件 M_Coder.c
我主要是用来生成试验课的菜单的。
#include <stdio.h>
#include <string.h>

#define BUFF_SIZE 200
#define NAME_SIZE 100

void Menu_Coder ()
{
int i, n;
char file_name[NAME_SIZE];
FILE *filepoint = NULL;

printf( "SOURCE FILE NAME:" );
scanf( "%s", file_name );
filepoint = fopen( file_name, "w" );
if ( filepoint == NULL ) {
fprintf( stderr, "ERROR: FILE %s HAVEN'T OPEN!\n ", file_name );
return;
}

printf( "So how many case do you want to insert?\n" );
scanf( "%d", &n );

fputs( "int choice;\n\n"
   "scanf( \"%%d\", &choice );\n"
   "switch ( choice ) {\n", filepoint);

for ( i = 0; i < n; i++ )
fprintf( filepoint, "case %d:work%d();\n"
   "break;\n", i, i );
fputs( "default:fprintf( \"stderr, \"Do Not Have This Choice!\\n\" );\n"
   "}\n", filepoint );

fclose( filepoint );
return;
}
这是头文件 header.h
void Header_Coder ();
void Menu_Coder ();
拙劣的作品,非常简单所以就不写文档了。