how to fix my error saying expected expression before 'else'

Posted by user292489 on Stack Overflow See other posts from Stack Overflow or by user292489
Published on 2010-03-25T05:02:23Z Indexed on 2010/03/25 5:13 UTC
Read the original article Hit count: 270

Filed under:
|
|
|

this program intended to read a .txt, a set of numbers, file and wwrite to another two .txt files called even amd odd as follows:

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
 int i=0,even,odd;
  int number[i];


  // check to make sure that all the file names are entered
  if (argc != 3) {
     printf("Usage: executable in_file  output_file\n");
      exit(0);
    }

  FILE *dog = fopen(argv[1], "r");
  FILE *feven= fopen(argv[2], "w");
  FILE *fodd= fopen (argv[3], "w");



// check whether the file has been opened successfully
  if (dog == NULL)
    { printf("File %s cannot open!\n", argv[1]);
      exit(0);
    }
  //odd = fopen(argv[2], "w");

  {  if
    (i%2!=1)
      i++;}

 fprintf(feven, "%d", even);
 fscanf(dog, "%d", &number[i]);
 else {
   i%2==1;
   i++;}
 fprintf(fodd, "%d", odd);
 fscanf(dog, "%d", &number[i]);

fclose(feven);
fclose(fodd);

© Stack Overflow or respective owner

Related posts about c

    Related posts about c++