Enviado em 11/06/2024 - 00:49h
tenho a seguinte função em C99 para uma agenda usando estrutura binaria:
void changeContact(PhoneBook **root, char *str)
{
if ((*root) != NULL)
{
if (strcasecmp((*root)->name, str) > 0)
{
changeContact(&(*root)->left, str);
}
else
{
if (strcasecmp((*root)->name, str) < 0)
{
changeContact(&(*root)->right, str);
}
else
{
if (strcmp((*root)->name, str) == 0)
{
int phone;
message6();
printf("\n\tNAME: %s", (*root)->name);
scanf(" %20[^\n]s", (*root)->name);
printf("\n\tNEW PHONE: ");
scanf(" %d", &phone);
(*root)->phone = phone;
message7();
}
}
}
}
else
{
message8();
}
}
void changeContact(PhoneBook **root, char *str)
{
int new_phone;
char new_name[20];
if ((*root) != NULL)
{
if (strcasecmp((*root)->name, str) > 0)
{
changeContact(&(*root)->left, str);
}
else
{
if (strcasecmp((*root)->name, str) < 0)
{
changeContact(&(*root)->right, str);
}
else
{
if (strcmp((*root)->name, str) == 0)
{
int choice;
message6();
printf("\n\tCURRENT NAME: %s", (*root)->name);
printf("\n\tCURRENT PHONE: %d", (*root)->phone);
printf("\n\n\tDo you want to change the name or phone?\n\tEnter (1-Name, 2-Phone, 0-Cancel): ");
scanf("%d", &choice);
switch(choice)
{
case 1:
printf("\n\tNEW NAME: ");
scanf("%20[^\n]s", new_name);
strcpy((*root)->name, new_name);
//(*root)->name = new_name;
message7();
break;
case 2:
printf("\n\tNEW PHONE: ");
scanf("%d", &new_phone);
strcpy((*root)->phone, new_phone);
//(*root)->phone = new_phone;
message7();
break;
default: printf("\n\tNO CHANGES.\n");
}
}
}
}
}
else
{
message8();
}
}
strcpy((*root)->name, new_name);
(*root)->name = new_name;
strcpy((*root)->phone, new_phone);
(*root)->phone = new_phone;
Resolver problemas de Internet
Como compartilhar a tela do Ubuntu com uma Smart TV (LG, Samsung, etc.)
Descritores de Arquivos e Swappiness
Solução rápida para o problema do Network Manager conectar mas não navegar
Como instalar no Linux Jogos da Steam só para Windows
Instalando o Team Viewer no Debian Trixie - problema no Policykit
Interface Gráfica no Linux Mint 22.1. (3)
Menu configurações e mudar plano de fundo não funcionam (5)