lundi 27 septembre 2021

How can I get this to print the new characters in a string properly in C?

Everytime I run this code, and I input something with the characters I want to be switched out with new characters, it only prints out the unchanged characters. What do I need to change to fix this?

#include <stdio.h>
#include "string.h"
int main()
{
 char originalPassword [50];
 char newPassword [50];
 int length;

printf("Please enter your current password. \n");
scanf("%s", originalPassword);
length = strlen(originalPassword);
for(int i = 0; i < length; i++)
{
    printf("%c\n", originalPassword[i]);
    if(originalPassword[i]=='i');
    {
       originalPassword[i] = '1';
    }
    
    if(originalPassword[i]=='a')
    {
       originalPassword[i]='@';
    }
    else
    {
        
    }
 }

}

Aucun commentaire:

Enregistrer un commentaire