Advertisement
HadoukenGr

Create Dictionary

Jan 18th, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4.  
  5.  
  6. int main (void)
  7. {
  8.     FILE *fp;
  9.     FILE *fp1;
  10.     FILE *fp2;
  11.     char words[30];
  12.     char size[30];
  13.     char *ptr;
  14.     char *ptr1;
  15.     int counter;
  16.  
  17.  
  18.     fp  = fopen("wordsgr.txt","r");
  19.     fp1 = fopen("wordssize.txt","r");
  20.     fp2 = fopen("dictionary.txt","w");
  21.  
  22.  
  23.     while(1)
  24.     {
  25.         ptr  = fgets(words,30,fp);
  26.         ptr1 = fgets(size,30,fp1);
  27.        
  28.         if (ptr == NULL || ptr1 == NULL)
  29.         {
  30.             break;
  31.         }
  32.     /*will search for newline character in string 1(size) and replace it with the terminating character \0 */
  33.           if (size[strlen(size)-1] == '\n')
  34.         {
  35.             size[strlen(size)-1] = '.';
  36.             size[strlen(size)] = '\0';
  37.         }
  38.        
  39.  
  40.         strcat(ptr1,ptr);
  41.         printf("%s",ptr1);
  42.         fprintf(fp2,"%s",ptr1);
  43.     }
  44.        
  45.     printf("\a");
  46.     fclose(fp);
  47.     fclose(fp1);
  48.     fclose(fp2);
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement