|
3楼 当然啦,这种繁琐的东西用电脑做最好,于是就有了下面的程序。把源文件的空格用 替换,制表格换成4空格。 用法: 在命令行(Dos/Windows/Unix/Linux)下运行。 格式: spacer [源文件] [新文件] 也可以用重定向 spacer old.c > new.c 然后把产生的新文件贴上来就可以了,下面的代码就是用它自己处理过的。 PS:在 Unix/Linux 下还可以当 filter,用在 pipe 中。 如:$cat hello.c | ./spacer | tee newhello.c | more #include <stdio.h> #include <stdlib.h> const char *s_license = "spacer 1.0.1 build 1. copyright © 2005 by akuma@tds\n" "\n" " This program is free software; you can redistribute it and/or modify\n" " it under the terms of the GNU General Public License as published by\n" " the Free Software Foundation; either version 2 of the License, or\n" " (at your option) any later version.\n" "\n" " This program is distributed in the hope that it will be useful,\n" " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" " GNU General Public License for more details.\n" "\n" " You should have received a copy of the GNU General Public License\n" " along with this program; if not, write to the\n" " Free Software Foundation, Inc.,\n" " 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n" "\n" " enter $%s [source] [destination]\n" "\n"; const int tab_size = 4; int main(int argc, char *argv[]) { FILE *sfile, *dfile; int key; int i, c; sfile = stdin; dfile = stdout; if (1 == argc) { fprintf(stderr, s_license, argv[0]); return EXIT_SUCCESS; } if (1 < argc) if (NULL == (sfile = fopen(argv[1], "r"))) { |
|
|
|
|
4楼 return -1; } if (2 < argc) { if (NULL == (dfile = fopen(argv[2], "w"))) { fprintf(stderr, "error: can't create file %s\n", argv[2]); fclose(sfile); return -2; } } if (3 < argc) fprintf(stderr, "warning: too many arguments, anything more than 2 will be discarded.\n"); while (c = fgetc(sfile), !feof(sfile)) switch ( c ) { case ' ': fputs(" ", dfile); break; case '\t': for (i = 0; i < tab_size; i++) fputs(" ", dfile); break; default: fputc(c, dfile); break; } fclose(dfile); fclose(sfile); return EXIT_SUCCESS; } /* Enjoy!! */ |
|
|
|
| 218.88.106.* |
5楼 |
|
|
|
8楼 现在才支持这样用: $cat hello.c ¦ spacer ¦ tee newhello.c ¦ more $spacer -h 看 license 信息。 $spacer 不加参数用时从 stdin 读入,stdout 输出。好像 Unix 的 cat。 #include <stdio.h> #include <stdlib.h> #include <ctype.h> const char *s_license = "spacer 1.0.2 build 1. copyright © 2005 by akuma@tds\n" "\n" " This program is free software; you can redistribute it and/or modify\n" " it under the terms of the GNU General Public License as published by\n" " the Free Software Foundation; either version 2 of the License, or\n" " (at your option) any later version.\n" "\n" " This program is distributed in the hope that it will be useful,\n" " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" " GNU General Public License for more details.\n" "\n" " You should have received a copy of the GNU General Public License\n" " along with this program; if not, write to the\n" " Free Software Foundation, Inc.,\n" " 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n" "\n" " enter $%s [source] [destination]\n" "\n"; const int tab_size = 4; const char *nbsp = " "; int main(int argc, char *argv[]) { FILE *sfile, *dfile; int i, c; sfile = stdin; dfile = stdout; if (2 == argc && '-' == argv[1][0] && 'h' == tolower(argv[1][1])) { fprintf(stderr, s_license, argv[0]); return EXIT_SUCCESS; } if (1 < argc) if (NULL == (sfile = fopen(argv[1], "r"))) { fprintf(stderr, "error: can't open file %s\n", argv[1]); return -1; } if (2 < argc) |
|
|
|
|
9楼 fprintf(stderr, "error: can't create file %s\n", argv[2]); fclose(sfile); return -2; } if (3 < argc) fprintf(stderr, "warning: too many arguments, anything more than 2 will be discarded.\n"); while (c = fgetc(sfile), !feof(sfile)) switch ( c ) { case ' ': fputs(nbsp, dfile); break; case '\t': for (i = 0; i < tab_size; i++) fputs(nbsp, dfile); break; default: fputc(c, dfile); break; } fclose(dfile); fclose(sfile); return EXIT_SUCCESS; } |
|
|
|
| 219.230.152.* |
12楼 |
|
|
|
13楼 |
|
|
|
| 219.134.64.* |
14楼 |
|
|
| 218.59.145.* |
16楼 |
|
|
|
19楼 #include <stdlib.h> #include <string.h> #include <ctype.h> const char *s_name = " spacer 1.0.4 build 1\n" " ----- copyright © 2005 by 8pm@baidu.cbar\n"; const char *s_license = " This program is free software; you can redistribute it and/or modify\n" " it under the terms of the GNU General Public License as published by\n" " the Free Software Foundation; either version 2 of the License, or\n" " (at your option) any later version.\n" "\n" " This program is distributed in the hope that it will be useful,\n" " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" " GNU General Public License for more details.\n" "\n" " You should have received a copy of the GNU General Public License\n" " along with this program; if not, write to the\n" " Free Software Foundation, Inc.,\n" " 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n" "\n" " enter $%s [source] [destination]\n" "\n"; const int tab_size = 4; const char *nbsp = " "; const char *amp = "&"; int main(int argc, char *argv[]) { FILE *sfile, *dfile; int i, c, n = 0; long s = 0, d = 0; sfile = stdin; dfile = stdout; fprintf(stderr, "%s", s_name); if (2 == argc && '-' == argv[1][0] && 'h' == tolower(argv[1][1])) { fprintf(stderr, s_license, argv[0]); return EXIT_SUCCESS; } if (1 < argc) if (NULL == (sfile = fopen(argv[1], "rb"))) { fprintf(stderr, "[] error: can't open file %s\n", argv[1]); |
|
|
|
|
20楼 } if (2 < argc) if (NULL == (dfile = fopen(argv[2], "wb"))) { fprintf(stderr, "[] error: can't create file %s\n", argv[2]); fclose(sfile); return -2; } if (3 < argc) fprintf(stderr, "[] warning: too many arguments, anything more than 2 will be discarded.\n"); fprintf(stderr, "%s", "[] processing ... "); while (c = fgetc(sfile), !feof(sfile)) switch (++s, ++n, c) { case ' ': d += strlen(nbsp); fputs(nbsp, dfile); break; case '&': d += strlen(amp); fputs(amp, dfile); break; case '\t': n--; for (i = 0; i < (tab_size - n % tab_size); i++) d += strlen(nbsp), fputs(nbsp, dfile); n += i; break; case '\n': n = 0; /* no break here */ default: ++d, fputc(c, dfile); break; } fprintf(stderr, "ok. transfered %ld byte(s) into %ld byte(s).\n", s, d); fclose(dfile); fclose(sfile); return EXIT_SUCCESS; } |
|
|
|
| 221.199.187.* |
21楼 |
|
|
| 61.175.123.* |
22楼 |
|
|
| 219.138.52.* |
23楼
|
|
|
|
24楼 AddToFunc StartFunction + I Module FvwmButtons MainPanel + I Module FvwmTaskBar + I Module FvwmPager + I MenuStyle * Font "StringEncoding=gb2312:xft:AR PL ShanHeiSun Uni:pixelsize=13:encoding=iso10646-1" + I Exec exec fcitx DestroyFunc InitFunction DestroyFunc ExitFunction AddToFunc ExitFunction ##+ I All (gnome-terminal) Close ##+ I All (firefox) Close Style "FvwmPager" StaysOnTop Style "FvwmTaskBar" StaysOnTop, NoTitle, BorderWidth 0 DestroyMenu RootMenu AddToMenu RootMenu "Root Menu" Title + "&Terminal" Exec exec gnome-terminal + "" Nop + "&Internet" Popup InternetMenu + "&Utility" Popup UtilityMenu + "" Nop + "&Exit Fvwm" Exit DestroyMenu InternetMenu AddToMenu InternetMenu "Internet" Title + "&Firefox" Exec exec firefox DestroyMenu UtilityMenu AddToMenu UtilityMenu "Utility" Title + "g&Vim" Exec exec gvim + "&StarDict" Exec exec stardict + "&Fcitx" Exec exec fcitx |
|
|
|
| 60.194.75.* |
27楼 {int n;/*定义整型变量*/ int score[10];/*定义数组名,有十个变量*/ for(n=0;n<9;n++)/*执行for循环语句*/ {scanf("%d",&score[n]);/*输入变量值*/ printf("%d\n",score[n]);}/*输出变量值*/ } |
|
|
| 60.25.131.* |
28楼 国际上通用的是3空格,大家可以将此句改称这句 const int tab_size = 3; |
|
|
| 219.82.81.* |
30楼 |
|
|
