[ create a new paste ] login | about

Link: http://codepad.org/rSxYx8Kr    [ raw code | output | fork ]

C, pasted on Dec 6:
#include <stdio.h>
#include <stdlib.h>
int main()
{
  FILE *S1, *S2, *S3;
  int x, y, n;
  float s = 0;
  printf("Введите количество чисел: ");
    scanf("%i", &n);
  int ar[n];
  char arr[n];
  S1 = fopen("S1.txt", "w");
  for(int i = 0; i < n; i++){
    printf("Введите число: ");
    scanf("%i", &x);
    fprintf(S1, "%i", x);
  }
  fclose(S1);
  S1 = fopen("S1.txt", "r");
  
  for(int i = 0; i < n; i++){
    fscanf(S1, "%s", &arr[i]);
  }
  for(int i = 0; i < n; i++){
    ar[i] = arr[i] - 48;
  }
  fclose(S1);
  for(int i = 0; i < n; i++){
    printf("%i\t", ar[i]);
  }

  for(int i = 0; i < n; i++){
    s += ar[i];
  }
  s = s/n;
  printf("\ns = %f", s);
  if(s > 2){
    printf("\nТык1");  
    S2 = fopen("S2.txt", "w");
    fprintf(S2, "%f\n", s);
    fclose(S2);
  } else {
    printf("\nТык2"); 
    S3 = fopen("S3.txt", "w");
    fprintf(S3, "%f\n", s);
    fclose(S3);  
  }
  return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
In function 'main':
Line 13: error: 'for' loop initial declaration used outside C99 mode
Line 21: error: redefinition of 'i'
Line 13: error: previous definition of 'i' was here
Line 21: error: 'for' loop initial declaration used outside C99 mode
Line 24: error: redefinition of 'i'
Line 21: error: previous definition of 'i' was here
Line 24: error: 'for' loop initial declaration used outside C99 mode
Line 28: error: redefinition of 'i'
Line 24: error: previous definition of 'i' was here
Line 28: error: 'for' loop initial declaration used outside C99 mode
Line 32: error: redefinition of 'i'
Line 28: error: previous definition of 'i' was here
Line 32: error: 'for' loop initial declaration used outside C99 mode


Create a new paste based on this one


Comments: