Doxygen Source Code Documentation
quotize.c File Reference
#include <stdio.h>
Go to the source code of this file.
Defines | |
#define | NBUF 256 |
Functions | |
int | main (int argc, char *argv[]) |
Define Documentation
|
Definition at line 9 of file quotize.c. Referenced by main(). |
Function Documentation
|
\** File : SUMA.c
Input paramters :
Definition at line 11 of file quotize.c.
00012 { 00013 char buf[NBUF] , buf2[NBUF*2]; 00014 int ll , num=0 , ii , jj ; 00015 00016 if( argc < 2 ){ 00017 fprintf(stderr,"Usage: quotize name < input > output\n" 00018 "Turns a text file into a C array of strings\n" 00019 "initialized into an array 'char * name[]'.\n" 00020 ) ; 00021 exit(0) ; 00022 } 00023 00024 printf("static char * %s[] = {\n",argv[1]) ; 00025 while( fgets(buf,NBUF,stdin) != NULL ){ 00026 ll = strlen(buf) ; if( ll == 0 ) break ; 00027 if( buf[ll-1] == '\n' ) buf[ll-1] = '\0' ; 00028 for( ii=0,jj=0 ; buf[ii] != '\0' ; ){ 00029 if( buf[ii] == '"' || buf[ii] == '\\' ) buf2[jj++] = '\\' ; 00030 buf2[jj++] = buf[ii++] ; 00031 } 00032 buf2[jj] = '\0' ; 00033 printf(" \"%s\\n\" ,\n" , buf2 ) ; 00034 num++ ; 00035 } 00036 printf(" NULL } ;\n") ; 00037 printf("#define NUM_%s %d\n",argv[1],num) ; 00038 exit(0) ; 00039 } |