It's intended to be a coder/decoder.
The program seems to jump over if(argv[1]=="c") and
if(argv[1]=="c") even if argv[1] is c or d, why??
If I write argv[1]=='c' the compiler says there's an error, so how I have to write argv[1]=="c", which a string, is that the error?
#include "stdio.h"
#include "stdlib.h"
main (int argc,char *argv[])
{
FILE *from,*to;
char ch,a;
if(argc!=4){
printf("USO: <c|d> <archivo> <archivosalida>");
exit(1);
}
if((from=fopen(argv[2],"rb"))==NULL){
printf("Error al abrir %s",argv[2]);
exit(1);
}
if((to=fopen(argv[3],"wb"))==NULL){
printf("Error al abrir %s",argv[3]);
exit(1);
}
if(argv[1]=="c"){
while(!feof(from)){
ch=fgetc(from);
a=ch-1;
fputc(a,to);
}
printf("Archivo codificado!!");
}
if(argv[1]=="d"){
while(!feof(from)){
ch=fgetc(from);
a=ch-1;
fputc(a,to);
}
printf("Archivo decodificado!!");
}
fclose(from);
fclose(to);
printf("Gracias por usar software Xuaco!!");
}