Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. // script.c
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. int main(void) {
  7.     static const char filename[] = "file";
  8.     FILE *file = fopen(filename, "r");
  9.  
  10.     if (file != NULL) {
  11.         char line[1024];
  12.         while(fgets(line, sizeof line, file) != NULL) {
  13.         line[strcspn (line, "\n")] = '\0';
  14.  
  15.         int lengthOfLine = strlen(line);
  16.         int word = 0;
  17.         int i;
  18.  
  19.         for (i = 0; i < lengthOfLine; i++) {
  20.             if (isalpha(line[i])) {
  21.             if (!word) {
  22.                 line[i] = (char) toupper (line[i]);
  23.                 word = 1;
  24.             }
  25.             } else {
  26.             word = 0;
  27.             }
  28.         }
  29.  
  30.         printf ("%s\n", line);
  31.         }
  32.  
  33.         fclose(file);
  34.     } else {
  35.         perror(filename);
  36.     }
  37.  
  38.     return 0;
  39. }