I'm doing a school project, and my focus is to copy several lines of a text file to an arrays of strings and then ask to the user which string they want to remove and write back the array on a file.
My program is opening the file and copying the content right to the array, but when I try to compare line by line with the string that the user gave me it doesn't go so well.
If I have in the file pedropedro and I want to remove it I need to compare all the elements of the array with pedropedro, I'm using strcmp, but it never returns 0 so I can't delete this line. Why is this happening? Stay safe.
if (strcmp("6",numero)==0)
    {
            char nome_elim[15];
            char pass_elim[15];
            char final_elim[30];
            char c;
            int i=0;
            int tamanho;
           printf("Insira o nome de utilizador que pretende eliminar:\n");
           scanf("%s",nome_elim);
           printf("Insira a password referent ao nome de utilizador:\n");
           scanf("%s",pass_elim);
           strcat(final_elim,nome_elim);
           strcat(final_elim,pass_elim);
           strcat(final_elim,"\n");
           
           printf("Vai adicionar: %s\n",final_elim);
           
           FILE *fptr =fopen("logins.txt","r+");
                                    
          if(fptr == NULL)
           {
              printf("Error!");   
             exit(1);             
           }else{
           char ch;
           int count =0;
           do{
           ch=fgetc(fptr);
           if(ch=='\n')count++;
           
           }while(ch!=EOF);
           rewind(fptr);
            tamanho=count;
           int i;
           for(i=0;i<count;i++){
           fscanf(fptr,"%s",cur_member[i].a);
           printf("%s\n",cur_member[i].a);
           
           }
           
           }
           int pos=0;
                   
           
           
              fclose(fptr);
           
           
           
                        
            
            FILE *fptr1 =fopen("logins.txt","w");
                                    
          if(fptr == NULL)
           {
              printf("Error!");   
             exit(1);   
             }
                
            
           for(int y=0;y<tamanho;y++)
          {
           if(strcmp(cur_member[y].a,final_elim)==0)
           {
           printf("IGUALIGUAL");
           continue;
           }
           else{
           printf("%d",y);
           fputs(cur_member[y].a,fptr1);
           fputs("\n",fptr1);
           }
           
           }
            fclose(fptr1);     
        
        strcpy(nome_elim,"\0");
        strcpy(pass_elim,"\0");
        strcpy(final_elim,"\0"); 
         
           
    }
 
    