C - How can I take words from file without numbers, special characters(, . ? &)? -


i want take words file.and send array. did fscanf. but, taking numbers, characters(, . % & # ! ?) , other things. how can control statement ?

int main(void)  {          char path[100];   printf("please, enter path of file: "); scanf("%s",&path);   file *dosya;   char kelime[1000][50];   int i=0;    if((dosya = fopen(path,"r")) != null)   {     while(!feof (dosya))     {         fscanf(dosya,"%s",&kelime[i]);         i++;     }   }   else{printf("not found file !");}   fclose(dosya); } 

use "%[]" distinguish between letters , non-letters.

#define nwords (1000) char kelime[nwords][50];  size_t i; (i=0; i<nwords; i++) {   // toss ("*" indicates not save) characters not ("^" indicates `not`) letters.   // ignore return value   fscanf(dosya, "%*[^a-za-z]");    // read letters   // expect return value of 1:success or eof:no more file read   // sure limit number of characters read: 49   if (fscanf(dosya, "%49[a-za-z]", kelime[i]) != 1) break; }  // `i` words 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -