Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <string.h>
  4.  
  5. int waga(char s[31]) {
  6.     int W = 0, l = strlen(s);
  7.     for (int i = 0; i < l; i++)
  8.         W += s[i];
  9.     return W;
  10. }
  11.  
  12. int main() {
  13.     char sl[30]="XDD";
  14.     FILE *slowa, *zwazone;
  15.     slowa = fopen("Slowa.txt", "r+");
  16.     zwazone = fopen("ZwazoneSlowa.txt", "w+");
  17.  
  18.  
  19.     char buf[20];
  20.     while(sl!=""){
  21.         fgets(sl,31,slowa);
  22.         sprintf(buf,"%i",waga(sl));
  23.         fputs(buf,zwazone);
  24.     }
  25.  
  26.     printf("OK.");
  27.     getch();
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement