fgetc_count_a.c |
---|
#include<stdio.h> #include<stdlib.h> int main(void){ FILE *fp; const char *filename1="/usr/share/dict/words"; const char *filename2="freqword-linux.txt"; const char *filename3="TomSawer1.txt"; int ch; int count; fp=fopen(filename1, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename1); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if( ch =='a'){ count++; } } printf("%s:%d\n", filename1, count); fclose(fp); fp=fopen(filename2, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename2); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if( ch =='a'){ count++; } } printf("%s:%d\n", filename2, count); fclose(fp); fp=fopen(filename3, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename3); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if( ch =='a'){ count++; } } printf("%s:%d\n", filename3, count); fclose(fp); return 0; } |
if(ch=='0' || ch=='1' ||...) |
if(ch>='0' && ...) |
fgetc_count_digit0.c |
---|
#include<stdio.h> #include<stdlib.h> int main(void){ FILE *fp; const char *filename1="/usr/share/dict/words"; const char *filename2="freqword-linux.txt"; const char *filename3="TomSawer1.txt"; int ch; int count; fp=fopen(filename1, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename1); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if( ch =='0' || ch=='1' || ch=='2' || ch=='3' || ch=='4' || ch=='5' || ch=='6' || ch=='7' || ch=='8' || ch=='9'){ count++; } } printf("%s:%d\n", filename1, count); fclose(fp); fp=fopen(filename2, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename2); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if( ch =='0' || ch=='1' || ch=='2' || ch=='3' || ch=='4' || ch=='5' || ch=='6' || ch=='7' || ch=='8' || ch=='9'){ count++; } } printf("%s:%d\n", filename2, count); fclose(fp); fp=fopen(filename3, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename3); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if( ch =='0' || ch=='1' || ch=='2' || ch=='3' || ch=='4' || ch=='5' || ch=='6' || ch=='7' || ch=='8' || ch=='9'){ count++; } } printf("%s:%d\n", filename3, count); fclose(fp); return 0; } |
fgetc_count_digit1.c |
---|
#include<stdio.h> #include<stdlib.h> int main(void){ FILE *fp; const char *filename1="/usr/share/dict/words"; const char *filename2="freqword-linux.txt"; const char *filename3="TomSawer1.txt"; int ch; int count; fp=fopen(filename1, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename1); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if( ch >='0' && ch <= '9'){ count++; } } printf("%s:%d\n", filename1, count); fclose(fp); fp=fopen(filename2, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename2); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if( ch >='0' && ch <= '9'){ count++; } } printf("%s:%d\n", filename2, count); fclose(fp); fp=fopen(filename3, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename3); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if( ch >='0' && ch <= '9'){ count++; } } printf("%s:%d\n", filename3, count); fclose(fp); return 0; } |
fgetc_count_digit2.c |
---|
#include<stdio.h> #include<stdlib.h> #include<ctype.h> int main(void){ FILE *fp; const char *filename1="/usr/share/dict/words"; const char *filename2="freqword-linux.txt"; const char *filename3="TomSawer1.txt"; int ch; int count; fp=fopen(filename1, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename1); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if(isdigit(ch)){ count++; } } printf("%s:%d\n", filename1, count); fclose(fp); fp=fopen(filename2, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename2); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if(isdigit(ch)){ count++; } } printf("%s:%d\n", filename2, count); fclose(fp); fp=fopen(filename3, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename3); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if(isdigit(ch)){ count++; } } printf("%s:%d\n", filename3, count); fclose(fp); return 0; } |
fgetc_count_line.c |
---|
#include<stdio.h> #include<stdlib.h> #include<ctype.h> int main(void){ FILE *fp; const char *filename1="/usr/share/dict/words"; const char *filename2="freqword-linux.txt"; const char *filename3="TomSawer1.txt"; int ch; int count; fp=fopen(filename1, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename1); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if(ch=='\n'){ count++; } } printf("%s:%d\n", filename1, count); fclose(fp); fp=fopen(filename2, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename2); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if(ch=='\n'){ count++; } } printf("%s:%d\n", filename2, count); fclose(fp); fp=fopen(filename3, "r"); if(fp==NULL){ printf("Can't Open File %s\n", filename3); exit(1); } count=0; while(1){ ch=fgetc(fp); if(ch==EOF){ break; } if(ch=='\n'){ count++; } } printf("%s:%d\n", filename3, count); fclose(fp); return 0; } |
fgetc_diff.c |
---|
#include<stdio.h> #include<stdlib.h> int main(void){ FILE *fp1, *fp2; const char *filename1="C.txt"; const char *filename2="C2.txt"; int ch1, ch2; int count=1; fp1=fopen(filename1, "r"); if(fp1==NULL){ printf("Can't Open File %s\n", filename1); exit(1); } fp2=fopen(filename2, "r"); if(fp2==NULL){ printf("Can't Open File %s\n", filename2); exit(1); } while(1){ ch1=fgetc(fp1); ch2=fgetc(fp2); if(ch1==EOF && ch2==EOF){ printf("Exactly Same\n"); break; } else if(ch1!=ch2){ printf("%d-th Characters (%c and %c) are different.\n", count, ch1, ch2); break; } count++; } fclose(fp1); fclose(fp2); return 0; } |
if(ch=='0' && ch=='1' &&...) |
if(ch=='0' || ch=='1' ||...) |
FILE *fp1,*fp2; const char *filename1="C.txt"; const char *filename2="C2.txt"; int ch1,ch2; int uh; uh=0; |
FILE *fp1,*fp2; int ch1,ch2; int uh; uh=0; const char *filename1="C.txt"; const char *filename2="C2.txt"; |
PS1="[\w] " |
.bashrc
をemacsで新規作成して、
PS1="[\w] " |
source .bashrc |
.bashrc
を削除するか名前変更して再ログインします。