Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- int isLegal(char *);
- int main(int argc, char *argv[]){
- char words[100];
- FILE *fp = fopen(argv[1], "r");
- if (fp == NULL) {
- printf("%s\n", "There was an error opening the file");
- return 1;
- }
- fscanf(fp, "%s", words);
- while (!feof(fp)) {
- if ( isLegal(words) ) {
- printf("%s\n", words);
- }
- fscanf(fp, "%s", words);
- }
- fclose (fp);
- return 0;
- }
- int isLegal(char *words) {
- int len = strlen(words);
- char foundFlag = 'y';
- for (int a=0; a<len; a++) {
- if ((words[a] < 'A' || words[a] > 'Z') && (words[a] < 'a' || words[a] > 'z'))
- foundFlag = 'n';
- }
- if (foundFlag == 'n')
- return 0;
- else
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement