Hi, I have a problem with the function

i=(abcdario[g]+h)%27;

, because i need to add this, but it gives me the error "invalid operands to binary +"

The full code is the following

#include<stdio.h>     //fopen() ,fclose() 
#include<stdlib.h>    //malloc()

int main (int argc, char*argv[])
{
     FILE *entrada, *salida;
     int caracter(unsigned char x);
     int caracter2(unsigned char x);     
     int f,g,h,i,j=1;
     char k,*b;
     typedef struct  
     {
         char min;
         char mayus;
     }alfabeto; 
     alfabeto abcdario[] = {{'a','A'},{'b','B'},{'c','C'},{'d','D'},{'e','E'},
                            {'f','F'},{'g','G'},{'h','H'},{'i','I'},{'j','J'},
                            {'k','K'},{'l','L'},{'m','M'},{'n','N'},{'ñ','Ñ'},
                            {'o','O'},{'p','P'},{'q','Q'},{'r','R'},{'s','S'},
                            {'t','T'},{'u','U'},{'v','V'},{'w','W'},{'x','X'},
                            {'y','Y'},{'z','Z'}};

    if ((argc==4||argc==5)
        &&(strcmp(argv[1],"E")==0||strcmp(argv[1],"e")==0
        ||strcmp(argv[1],"D")==0||strcmp(argv[1],"d")==0)
        &&(isdigit(argv[2][0])!=0||isdigit(argv[2][1])!=0)
        &&((entrada=fopen(argv[3], "r"))!=NULL)) 
    {   
        b=argv[1];
        h=atoi(argv[2]);
    }
    else
   	{
		printf("\nError de argumentos\n",160);
		system ("pause");
		return 0;
    }
    
    if (argc!=5)
        j=0;
    else 
        salida=fopen(argv[4], "w");
    if(h!=0)  
	{if(*argv[1]=='d'||*argv[1]=='D')
	    h>0?(h=27-(h%27)):(h=-(h%27));
	else
        h>0?(h=(h%27)):(h=27+(h%27));  } 
     
     
     while(k!=EOF)
     {
         k=getc(entrada);         
         if(caracter(k))
         k=caracter2(k);
         if(k==EOF)
         break;
         else
         {
		         for (g=0;g<=26;g++)
                 {
                     if(abcdario[g].mayus==k)
                     {
                         i=(abcdario[g]+h)%27;
                         if(abcdario[i].mayus==abcdario[14].mayus&&j==0)
                         {printf("%c",'\245');break;}
                         j?putc(abcdario[i].mayus,salida):printf("%c",
                         abcdario[i].mayus);
                         break;
                     }
                     else
                         if(abcdario[g].min==k)
                         {
                             i=(abcdario[g]+h)%27;
                             if(abcdario[i].min==abcdario[14].min&&j==0){printf
                             ("%c",'\244');break;}
                             j?putc(abcdario[i].min,salida):printf("%c",abcdario
                             [i].min);
                             break;
                         }
                         else
                             if(j==26) {j?putc(k,salida):printf("%c",k);}
                         
                 }
         }
     }
     fclose(entrada);
     if(j)fclose(salida);
     return 0;
}
             


int caracter(unsigned char x)
{
	if (isalpha(x)||x==225||x==193||x==233||x==201||x==237||x==205||x==243
        ||x==211||x==250||x==218||x==252||x==220||x==241||x==209)
		return 1;
	else
		return 0;
}
int caracter2(unsigned char x)
{
	if (x==225)return 'a';else
    if (x==193)return 'A';else
	if (x==233)return 'e';else    
	if (x==201)return 'E';else
	if (x==237)return 'i';else
	if (x==205)return 'I';else
	if (x==243)return 'o';else
	if (x==211)return 'O';else
	if (x==250||x==252)return 'u';else
	if (x==218||x==220)return 'U';else
	if (x==241)return 241;else
	if (x==209)return 209;else
	return (x);
}


Waiting for your answers
thanks

> i=(abcdario[g]+h)%27;
The array is an array of structs, so you need something like i=(abcdario[g].min+h)%27;

Hi again, I made a new change in it, and the compilator dosn't give me problems, but when I try to open it by DOS, it ruterns a error, can someone help me with this plz

#include<stdio.h>     //fopen() ,fclose() 
#include<stdlib.h>    //malloc()

int main (int argc, char*argv[])
{
     FILE *entrada, *salida;
     int caracter(unsigned char x);
     int caracter2(unsigned char x);     
     int f,g,h,i,j=1;
     char k,*b;
     typedef struct  
     {
         char min;
         char mayus;
     }alfabeto; 
     alfabeto abcdario[] = {{'a','A'},{'b','B'},{'c','C'},{'d','D'},{'e','E'},
                            {'f','F'},{'g','G'},{'h','H'},{'i','I'},{'j','J'},
                            {'k','K'},{'l','L'},{'m','M'},{'n','N'},{'ñ','Ñ'},
                            {'o','O'},{'p','P'},{'q','Q'},{'r','R'},{'s','S'},
                            {'t','T'},{'u','U'},{'v','V'},{'w','W'},{'x','X'},
                            {'y','Y'},{'z','Z'}};

    if ((argc==4||argc==5)
        &&(strcmp(argv[1],"E")==0||strcmp(argv[1],"e")==0
        ||strcmp(argv[1],"D")==0||strcmp(argv[1],"d")==0))
    {   
        b=argv[1];
        h=atoi(argv[2]);
    }
    else
   	{
		printf("\nError de argumentos\n",160);
		system ("pause");
		return 0;
    }
    
    if (argc!=5)
        j=0;
    else 
        salida=fopen(argv[4], "w");
    if(h!=0)  
	{if(*argv[1]=='d'||*argv[1]=='D')
	    h>0?(h=27-(h%27)):(h=-(h%27));
	else
        h>0?(h=(h%27)):(h=27+(h%27));  } 
     
     
     while(k!=EOF)
     {
         k=getc(entrada);         
         if(caracter(k))
         k=caracter2(k);
         if(k==EOF)
         break;
         else
         {
		         for (g=0;g<=26;g++)
                 {
                     if(abcdario[g].mayus==k)
                     {
                         i=(g+h)%27;//Here is were I change the program
                         if(abcdario[i].mayus==abcdario[14].mayus&&j==0)
                         {printf("%c",'\245');break;}
                         j?putc(abcdario[i].mayus,salida):printf("%c",
                         abcdario[i].mayus);
                         break;
                     }
                     else
                         if(abcdario[g].min==k)
                         {
                             i=(g+h)%27; // Here to, with the same argumment
                             if(abcdario[i].min==abcdario[14].min&&j==0){printf
                             ("%c",'\244');break;}
                             j?putc(abcdario[i].min,salida):printf("%c",abcdario
                             [i].min);
                             break;
                         }
                         else
                             if(j==26) {j?putc(k,salida):printf("%c",k);}
                         
                 }
         }
     }
     fclose(entrada);
     if(j)fclose(salida);
     return 0;
}
             


int caracter(unsigned char x)
{
	if (isalpha(x)||x==193||x==201||x==205||x==209||x==211||x==218||x==220
        ||x==225||x==233||x==237||x==241||x==243||x==250||x==252)
		return 1;
	else
		return 0;
}
int caracter2(unsigned char x)
{
	if(x==193)return 'A';else if(x==201)return 'E';else	if(x==205)return 'I';
    else if(x==209)return 209;else if(x==241)return 241;
    else if(x==211)return 'O';else if(x==225)return 'a';
    else if(x==233)return 'e';else if(x==237)return 'i';
    else if(x==243)return 'o';else if(x==218||x==220)return 'u';
    else if(x==250||x==252)return 'u';else return (x);
}

Thanks

Since there are over 400 errors that can be returned, could you please be less vague and tell us what the error is, and where?

What compiler are you using because mine gives a couple errors about using uninitialized variables which you need to fix before attempting to run that program.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.