Ir ao conteúdo
  • Cadastre-se

C Nao estou conseguinfo efetuar o login


Murilo Murilo
Ir à solução Resolvido por devair1010,

Posts recomendados

Código:
 

Spoiler

# include"stdio.h"
# include"stdlib.h"
# include"string.h"
# include"locale.h"
#include <time.h>
# define  SIZE  53

// Definição das variáveis

char nome [SIZE] [ 50 ];
char email [SIZE] [ 50 ];
int datanasc [SIZE];
int cpf [SIZE];
char convidado [SIZE] [ 1 ];
char especial [SIZE] [ 1 ];
int op, t, opcaomp, encontrou;
int j;
int verifica_senha = 0 ;
int verifica_user = 0 ;
char login [ 10 ];
char senha [ 8 ];

// int status_es [3];
// int status_cv [10];
// int status_pt [40];

int status [ 53 ];

int assento [SIZE];

// Definição das variáveis de funções
void email_todos ();//corrigir erro 675;
void  incluir ();
void  excluir ();
void  listar_livres ();
void realizar_sorteio ();
void  enviar_email ();//corrigir erros629;
void email_um();//corrigir erro 705;

void  listar_todos ();//corrigir erro line480;
void  valida_senha ();
void  gerenciar_visitante ();//line198;

// Rotina principal

int  main (void)
{

setlocale (LC_ALL, " portuguese " );

do
{
    system ( " clear " );
   
    printf ( " \n\n\n\n\n\n\n\t\t\t\t\t\t + ======================== ============================================ + " );
    printf ( " \n\t\t\t\t\t\t | | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxx xxxx  xxxx     xxxx xxxx xxxxxxxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxx xxxx  xxxxxx   xxxx xxxx xxxx xxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxx xxxx  xxxx xx  xxxx xxxx xxxx xxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxx xxxx  xxxx  xx xxxx xxxx xxxxxxxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxxxxxxx  xxxx   xxxxxx xxxx xxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxxxxxxx  xxxx    xxxxx xxxx xxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | | \n " );
    printf ( " \t\t\t\t\t\t\t | | \n " );
    printf ( "\t\t\t\t\t\t\t\t| UNIVERSIDADE PAULISTA | \n " );
    printf ( "\t\t\t\t\t\t | | \n " );
    printf ( " \t\t\t\t\t\t | | \n" );
    printf ( " \t\t\t\t\t\t| PALESTRA DIREITOS HUMANOS |\n");
    printf ( " \t\t\t\t\t\t| | \n" );
    printf ( " \t\t\t\t\t\t+ ====================================== ============================ + " );
    printf ( " \n\n\t\t\t\t\t\t  USUÁRIO .........: " );
    scanf("%c", login);
    //fflush(stdin);
    printf ( " \n\n\t\t\t\t\t\t  SENHA ...........: " );
    scanf("%c", senha);
     
    // Chama função para validar a senha
    //valida_senha ();

    if (verifica_senha == 1 )
    {
        opcaomp = 0 ;

        // Setar todos os assentos como livres
        for (j = 0 ; j < 52 ; j ++)
        {
          status [j] = 0 ;    // 0 - Assento livre -> 1 - Assento ocupado
        }


        // Apresenta a tela de menu principal

        while (opcaomp != 4 )
        {
            
            verifica_senha = 1 ;
            system ( " clear " );
            printf ( "  \n\n\n\n\n\n\t\t\t\t\t\t+======================== ============================================== + " );
            printf ( " \n \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | UNIP - UNIVERSIDADE PAULISTA | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | **** MENU PRINCIPAL **** | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | 1 - Gerenciar Visitante | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | 2 - Realizar Sorteio | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | 3 - Enviar Comunicado por E-mail | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | 4 - Sair | \n " );
            printf ( " \t \t \t \t  \t \t| | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t + ====================================== ============================== + \n \n " );
            printf ( " \t \t \t \t \t \t                   Digite a opção desejada ......: " );
            scanf ( "%d " , & opcaomp);
            switch (opcaomp)
            {

                case  1 :
                    gerenciar_visitante ();
                    break ;

                case  2 :
                    realizar_sorteio ();
                    break ;

                case  3 :
                    enviar_email ();
                    break;

                case  4 :
                    system ( " exit " );
                    break ;

                padrão :
                    printf ( " \n \t \t \t \t \t \t \t \t *** Opção Inválida! *** " );
                    getchar ();

            } // Switch
        } // while (opcaomp! = 4)
    } // se (verifica_senha == 1)

} while (t != 3 && verifica_senha == 0 );

} // Main

// Função Valida Senha e Usuario

void  valida_senha ()
{
    int i, u;
    char c;
    char l;
    u = 0 ;
    i = 0 ;

    while ((c = getchar ()) != 13 )
    {
       senha [i] = c;
       login [u] = l;
       u ++;
       i ++;
       printf ( " * " );
    }

    login [u] =  0  ;
    senha [i] =  0 ;
    i = 0 ;
    u = 0 ;
    l = strcmp (login, " adm " );
    c = strcmp (senha, " 1 " );

    if (c == 1 && l == 1 ) // Senha e usuario Inválida
    {
        printf ( " \n \n \t \t \t \t \t *** Senha ou Usúario inválido! Tente novamente *** \n \n " );
        t = t + 1 ;
        system ( " cor 0c " );
        getchar ();
    }
    else // Senha e Usuario Correta
    {
        verifica_user = 1 ;
        verifica_senha = 1 ;
    }
    if (t == 3 )
    {
      // sistema ("cls");
      printf ( " \n \n \t \t \t \t \t *** Acesso Negado! *** \n \n " );
      getchar (); 
    }
} // Fim da Função Valida Senha e Usuario

// Função Gerenciar Visitante

void  gerenciar_visitante ()
{

    int j, op;

    op = 1 ;

    while (op != 5 )
    {
       system ( " cls " );
       printf ( " \n \n \n \n \n \n \t \t \t \t \t \t + ======================== ============================================== + " );
       printf ( " \n \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | UNIP - UNIVERSIDADE PAULISTA | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 1 - Incluir Participante | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 2 - Excluir Participante | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 3 - Listar Lugares Livres | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 4 - Mostrar Todos os Lugares | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 5 - Retornar ao Menu Principal | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t + ====================================== ============================== + \n \n " );
       printf ( " \t \t \t \t \t \t                   Digite a opção desejada ......: " );
       scanf ( "%d " , &op);

       switch (op)
       {
          case  1 :   // Incluir o participante
             incluir ();
            break ;

          case  2 :
             excluir ();
            break ;

          case  3 :
            listar_livres ();
            break ;

          case  4 :
            listar_todos ();
            break;

          case  5 :
           break ;

          default: 
            printf ( " \n \t \t \t \t \t \t \t \t *** Opção Inválida! *** " );
            getchar ();
            break;

       } // Switch
    } // enquanto (opcao! = 5)
} // Fim da Função Gerenciar Visitante

// Função incluir participantes

void  incluir ()
{
    static  int linha;

    int j, encontrou, tc, i, v;
    linha = 0 ;

    do {

       encontrou =0 ;
       tc =0 ;

       // Mostrar tela para digitação das informações do participante

       system ( " clear " );
       printf ( " \n \n \n \n \n \n \t \t \t \t \t \t \t *** Cadastro de Participantes *** \n \n \n " );
       printf ( " \n \t \t \t \t \t \t Nome ................................ ...: " );
       fflush (stdin);
       scanf("%[^\n]s%*c",nome[linha]);


       printf ( " \n \t \t \t \t \t \t Número do CPF ..........................: " );
       scanf ( "%d " , & cpf [linha]);
       printf ( " \n \t \t  \t \t \t \t Data de nascimento .....................: " );
       scanf ( "%d " , & datanasc [linha]);
       printf ( " \n \t \t \t \t \t \t E-mail .............................. ...: " );
       fflush (stdin);
       scanf ("%[^\n]s%*c", email[linha]);
       printf ( " \n \t \t \t \t \t \t É convidado do palestrante (S / N)? .....: " );
       scanf( "%[^\n]s%*c" , convidado[linha]);
       printf ( " \n \t \t \t \t \t \t Necessita de lugar especial (S / N)? ....: " );
       scanf( "%[^\n]s%*c", especial[linha]);

       // Verifica assentos reservados e reserva assento disponível

       system ( " clear " );

       // Assento Especial
       tc = strcmp (especial [linha], " S " );
       if (tc == 0 )
       {
        for (j = 0 ; j < 3 ; j++)
          {
           if (status [j] == 0 )
            {
               printf ( " \n \n \n \n \n \n \t \t \t \t \t \t Olá %s " , nome [linha]);
               printf ( " \n \n \t \t \t \t \t \t Seu assento é número: % d " , j + 1 );
               printf ( " \n \n \t \t \t \t \t \t Esperamos que aproveite a Paletra !!! " );
               status [j] = 1 ;
               cpf [j] = cpf [linha];
               getchar ();
               j = 3 ;
               encontrou = 1 ;
               op = 0 ;
            }
          }
       }

       //outro
       {
       // Convidado do Palestrante
       tc = strcmp (convidado [linha], " S " );
       if (tc == 0 )
       {
          for (j = 3 ; j < 13 ; j ++)
          {
            if (status [j] == 0 )
            {
               printf ( " \n \n \n \n \n \n \t \t \t \t \t \t Olá %s " , nome [linha]);
               printf ( " \n \n \t \t \t \t \t \t Seu assento é número: % d " , j + 1 );
               printf ( " \n \n \t \t \t \t \t \t Esperamos que aproveite a Paletra !!! " );
               status [j] = 1 ;
               cpf [j] = cpf [linha];
               getchar ();
               j = 14 ;
               encontrou = 1 ;
               op = 0 ;
            }
          }
       }
       //outro
       {

       // Participante

          for (j = 13 ; j < 52 ; j ++)
          {
            // i = pt [j];
            if (status [j] == 0 )
            {
               printf ( " \n \n \n \n \n \n \t \t \t \t \t \t Olá %s " , nome[linha]);
               printf ( " \n \n \t \t \t \t \t \t Seu assento é número: % d " , j + 1 );
               printf ( " \n \n \t \t \t \t \t \t Esperamos que aproveite a Paletra !!! " );
               cpf [j] = cpf [linha];
               status [j] = 1 ;
               getchar ();
               j = 53 ;
               encontrou = 1 ;
               op = 0 ;
            }
          }
       }

    }
    if (encontrou == 0 )
    {
       printf ( " *** Todos os assentos estão ocupados! *** " );
       getchar ();
    }

    linha ++;
    printf ( " % d  % d " , cpf [linha], linha);
    } while(op == 1 );
} // Fim da função incluir

// Excluir participante liberando o assento
void  excluir ()
{
    int cpfPesquisa;
    int i;

    system ( " clear " );
    printf ( " \n \n \n \n \n \n \t \t \t \t \t \t \t Informe o CPF do participante que deseja excluir: " );
    scanf ( "%d" , & cpfPesquisa);
      for (i = 0 ; i <SIZE; i++)
    {
       if (cpf [i] == cpfPesquisa)
       {
          status [i] = 0 ;
          cpf [i] = 0 ;
          datanasc [i] = 0 ;
          i = 54 ;
          printf ( " \n \n \n \t \t \t \t \t \t \t *** Registro excluído com sucesso! *** " );
          getchar ();
       }
    }
} // Fim da função excluir participante


// Função Listar lugares livres no auditório

void  listar_livres ()
{
    int j;

    system ( " clear " );
    printf ( " \n \n \n \n \n \n \t \t \t \t \t \t \t *** Lugares Livres *** \n \n \n " );
    encontrou = 0 ;  // Bandeira para saber se existe pelo menos um assento livre

    printf ( " \n \n \n \t \t \t \t \t \t Assentos Especiais \n \n " );
    printf ( " \t \t \t \t \t \t Fileira A " );
      for (j = 0 ; j < 3 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "%d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Assentos para Convidados do Palestrante \n \n " );
    printf ( " \t \t \t \t \t \t Fileira B " );
      for (j = 3 ; j < 13 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "%d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Assentos para Participantes \n \n " );
    printf ( " \t \t \t \t \t \t Fileira C " );
      for (j = 13 ; j < 23 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "%d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( "\n" );
    printf ( " \t \t \t \t \t \t Fileira D " );
      for (j = 23 ; j < 33 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "% d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t Fileira E " );
      for (j = 33 ; j < 43 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "%d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( "\n" );
    printf ( " \t \t \t \t \t \t Fileira F " );
     for (j = 43 ; j < 53 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "%d" , j + 1 );
            encontrou = 1 ;
        }
    }

    getchar ();
 }

 // Função Lista todos os lugares do auditório

void  listar_todos ()
{
    int j;
    system ( " clear " );

    printf ( " \n \n \n \n \t \t \t \t \t \t \t      Todos os Lugares     \n " );
    printf ( " \t \t \t \t \t \t + ====================================== ============================ + " );
    encontrou = 0 ;  // Bandeira para saber se existe pelo menos um assento livre
    printf ( " \n \t \t \t \t \t \t \t   *** Livres ***   \n " );
    printf ( " \n \n \t \t \t \t \t \t Assentos Especiais \n " );
    printf ( " \t \t  \t \t \t \t A " );
      for (j = 0 ; j < 3 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "%d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Convidados do Palestrante \n " );
    printf ( " \t \t \t \t \t \t B " );
     for(j = 3 ; j < 13 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "% d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Participantes \n " );
    printf ( " \t \t \t \t \t \t C " );
      for (j = 13 ; j < 23 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t D " ); 
        for (j = 23 ; j < 33 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }
    printf ( " \n " );
    printf ( " \t \t \t \t \t \t E " );
      for (j = 33 ; j < 43 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t F " );
      for (j = 43 ; j < 53 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    // função para ver todos os ocupados
    printf ( " \n \n \n \t \t \t \t \t \t + ============================== ========================= + " );
    encontrou = 0 ;  // Bandeira para saber se existe pelo menos um assento livre
    printf ( " \n \t \t \t \t \t \t \t   *** Ocupados ***   \n " );
    printf ( " \n \t \t \t \t \t \t Assentos Especiais \n " );
    printf ( " \t \t \t \t \t \t A " );
        for (j = 0 ; j < 3 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 0 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Convidados do Palestrante \n " );
    printf ( " \t \t \t \t \t \t B " );
      for (j = 3 ; j < 13 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 0 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Participantes \n " );
    printf ( " \t \t \t \t \t \t C " );
      for (j = 13 ; j < 23 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t D " );
      for (j = 23 ; j < 33 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t E " );
      for (j = 33 ; j < 43 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t F " );
    for (j = 43 ; j < 53 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    getchar ();

}


void enviar_email ()   // erro nessa parte 
{

        int opM;
    opM = 1 ;

    while (opM != 3 )
    {
        system ( " clear " );
       printf ( " \n \n \n \n \n \n \t \t \t \t \t \t + ======================== ============================================== + " );
       printf ( " \n \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | UNIP - UNIVERSIDADE PAULISTA | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 1 - Todos os Visitantes | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 2 - Escolher Visitante | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 3 - Retornar ao Menu Principal | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t + ====================================== ============================== + \n \n " );
       printf ( " \t \t \t \t \t \t                   Digite a opção desejada ......: " );
       scanf ( "%d " , &opM);

              switch (opM)
            {

                case  1 :
                    email_todos ();
                    break ;

                case  2 :
                    email_um ();
                    break ;

                case  3 :
                   break ;

                padrão :
                    printf ( " \n \t \t \t \t \t \t \t \t *** Opção Inválida! *** " );
                    getchar ();
            }
    }
}

void  email_todos ()
{

        system ( " cls " );
       printf ( " \n \n \n \n \n \n \t \t \t \t \t \t + ======================== ============================================== + " );
       printf ( " \n \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | Palestra Direito Humanos | \n " );
       printf ( " \t \t \t \t \t \t | Dr. Ramiro | \n " );
       printf ( " \t \t \t \t \t \t | Contéudo da Palestra: Direitos Humanos | \n " );
       printf ( " \t \t \t \t \t \t | Motivo: Informativo | \n " );
       printf ( " \t \t \t \t \t \t | Data: 25/12/2020 Horário: 18:30 | \n " );
       printf ( " \t \t \t \t \t \t | Local: Unip - Chácara Santo Antônio | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | Resumo | \n " );
       printf ( " \t \t \t \t \t \t | Hoje em dia as pessoas torcem o nariz para palavra | \n " );
       printf ( " \t \t \t \t \t \t | ?? Direitos Humanos ??, pois aqui no Brasil ela sempre | \n " );
       printf ( " \t \t \t \t \t \t | sempre está ligada ao crime e violência e nunca | \n " );
       printf ( " \t \t \t \t \t \t | está ao lado da vítima, mas sim daquela | \n " );
       printf ( " \t \t \t \t \t \t | causaram o Dano. Porém o que ninguém sabe que | \n " );
       printf ( " \t \t \t \t \t \t | na década de 40 em uma reunião em paris, foram | \n " );
       printf ( " \t \t  \t \t \t \t | lançados 30 artigos no rastro da segunda guerra |  \n " );
       printf ( " \t \t \t \t \t \t | Mundial, pois a falta de punição contra governos | \n " );
       printf ( " \t \t \t \t \t \t | autoritários, trabalho escravo, tortura, discriminação, | \n " );
       printf ( " \t \t \t \t \t \t | fome e pobreza violava todos os dias a vida dos seres | \n " );
       printf ( " \t \t \t \t \t \t | humanos da época. | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t + ====================================== ============================== +  \n \n " );
       getchar ();
}

void  email_um ()
{
    int as;
    printf ( " \t \t \t \t \t \t Escolha o Assento abaixo, Assim o e-mail será enviado para pessoa que está sentada no mesmo. \n " );
    encontrou = 0 ;  // Bandeira para saber se existe pelo menos um assento livre
    printf ( " \n \t \t \t \t \t \t Assentos Especiais \n " );
    printf ( " \t \t \t \t \t \t A " );
      for(j = 0 ; j < 3 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 0 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Convidados do Palestrante \n " );
    printf ( " \t \t \t \t \t \t B " );
    for (j = 3 ; j < 13 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 0 ;
        }
    }

    printf ( "  \n \n \n \t \t \t \t \t \t Participantes \n " );
    printf ( " \t \t \t \t \t \t C " );
    for (j = 13 ; j < 23 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t D " );
    for (j = 23 ; j < 33 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( "  \n" );
    printf ( " \t \t \t \t \t \t E " );
    for (j = 33 ; j < 43 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t F " );
    for (j = 43 ; j < 53 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n \t\t \t \t \t \t \t \t Necessário apenas o número do assento \n " );
    printf ( " \t \t \t \t \t \t \t \t Assento ......: " );
    scanf ( " %d " , &as);

    system ( " clear " );
    if (as> 0 && as < 54 ) {

       printf ( " \n \n \n \n " );
       printf ( " \n \n \n \n \t \t \t \t \t \t Assento: % d  \n " , as);
       printf ( " \t \t \t \t \t \t Email Enviado com Sucesso !!! \n \n " );
       printf ( " \t \t \t \t \t \t Conteúdo: \n " );
       printf ( " \t \t \t \t \t \t + ====================================== ============================== + " );
       printf ( " \n \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | Palestra Direito Humanos | \n " );
       printf ( " \t \t \t \t \t \t | Dr. Ramiro | \n " );
       printf ( " \t \t \t \t \t \t | Contéudo da Palestra: Direitos Humanos | \n " );
       printf ( " \t \t \t \t \t \t | Solicitação do Assento: % d                                | \n " , as);
       printf ( " \t \t \t \t \t \t | Motivo: Para Envio do Informativo | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | Data: 13/12/2018 Horário: 18:30 | \n " );
       printf ( " \t \t \t \t \t \t | Local: Unip - Chácara Santo Antônio | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | Resumo | \n " );
       printf ( " \t \t \t \t \t \t | Hoje em dia as pessoas torcem o nariz para palavra | \n " );
       printf ( " \t \t \t \t \t \t | ?? Direitos Humanos ??, pois aqui no Brasil ela sempre | \n " );
       printf ( " \t \t \t \t \t \t | sempre está ligada ao crime e violência e nunca | \n " );
       printf ( " \t \t \t \t \t \t | está ao lado da vítima, mas sim daquela | \n " );
       printf ( " \t \t \t \t \t \t | causaram o Dano. Porém o que ninguém sabe que | \n " );
       printf ( " \t \t \t \t \t \t | na década de 40 em uma reunião em paris, foram | \n " );
       printf ( " \t \t \t \t \t \t | lançados 30 artigos no rastro da segunda guerra | \n " );
       printf ( " \t \t \t \t \t \t | Mundial, pois a falta de punição contra governos | \n " );
       printf ( " \t \t \t \t \t \t | autoritários, trabalho escravo, tortura, discriminação, | \n " );
       printf ( " \t \t \t \t \t \t | fome e pobreza violava todos os dias a vida dos seres | \n " );
       printf ( " \t  \t \t \t \t \t | humanos da época. | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t + ====================================== ============================== + \n \n " );

       getchar ();

    }
    else {
       printf ( " \t \t \t \t \t \t Assento Inválido \n " );
       getchar ();
    }
       getchar ();

}

void  realizar_sorteio ()
{
    srand (time(0)); // escolhe sequencia de numeros aleatorios
    int valores [] = { 1 , 2 , 3 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 34 , 35 , 36 , 37 ,38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , 48 , 49 , 50 , 51 , 52 , 53 };
    int n = sizeof valores / sizeof * valores;
    n =rand()%53;
    printf ( " \t \t \t \t \t \t \t \t + ================================== == + \n " );
    printf ( " \t \t \t \t \t \t \t \t PARABÉNS !!!! \n " );
    printf ( " \t \t \t \t \t \t \t \t *** Assento: % d *** \n " , valores [ rand ()%n]);
    printf ( " \t  \t \t \t \t \t \t \t Você foi Sorteado !!!!! " );
    getchar ();
}

 

  • Amei 1
Link para o comentário
Compartilhar em outros sites

  • Solução

@Murilo Murilo      parece que você está usando o linux , então para adaptar para Windows precisa modificar alguns comandos e  seu código modificado poderia ser assim :

#define _CRT_SECURE_NO_WARNINGS  // para usar scanf bem
#ifdef _WIN32
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#define cls system("cls");
#define sair exit(128);
#define DIV 1048576 
#define WIDTH 7
#endif

#ifdef linux
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define cls system(" clear ");
#define sair system(" exit ");
#endif

# include "stdio.h"
# include "conio.h"
# include <iomanip>
# include "stdlib.h"
# include "string.h"
# include "locale.h"
#include  <time.h>
//#include "pch.h"
#include <iostream>
#define getch() _getch()
# define  SIZE  53

// Definição das variáveis

char nome[SIZE][50];
char email[SIZE][50];
int datanasc[SIZE];
int cpf[SIZE];
char convidado[SIZE][1];
char especial[SIZE][1];
int op, t, opcaomp, encontrou;
int j;
int verifica_senha = 0;
int verifica_user = 0;
char login[10];
char senha[8];

// int status_es [3];
// int status_cv [10];
// int status_pt [40];

int status[53];

int assento[SIZE];

// Definição das variáveis de funções
void email_todos();//corrigir erro 675;
void  incluir();
void  excluir();
void  listar_livres();
void realizar_sorteio();
void  enviar_email();//corrigir erros629;
void email_um();//corrigir erro 705;

void  listar_todos();//corrigir erro line480;
int  valida_senha();
void  gerenciar_visitante();//line198;

// Rotina principal

int  main()
{
    setlocale(LC_ALL, " portuguese ");
    char ax[11];
    do
    {
        cls

        printf(" \n\n\n\n\n\n\n\t\t\t\t\t\t + ======================== ============================================ + ");
        printf(" \n\t\t\t\t\t\t | | \n ");
        printf(" \t\t\t\t\t\t\t | xxxx xxxx  xxxx     xxxx xxxx xxxxxxxxx | \n ");
        printf(" \t\t\t\t\t\t\t | xxxx xxxx  xxxxxx   xxxx xxxx xxxx xxxx | \n ");
        printf(" \t\t\t\t\t\t\t | xxxx xxxx  xxxx xx  xxxx xxxx xxxx xxxx | \n ");
        printf(" \t\t\t\t\t\t\t | xxxx xxxx  xxxx  xx xxxx xxxx xxxxxxxxx | \n ");
        printf(" \t\t\t\t\t\t\t | xxxxxxxxx  xxxx   xxxxxx xxxx xxxx | \n ");
        printf(" \t\t\t\t\t\t\t | xxxxxxxxx  xxxx    xxxxx xxxx xxxx | \n ");
        printf(" \t\t\t\t\t\t\t | | \n ");
        printf(" \t\t\t\t\t\t\t | | \n ");
        printf("\t\t\t\t\t\t\t\t| UNIVERSIDADE PAULISTA | \n ");
        printf("\t\t\t\t\t\t | | \n ");
        printf(" \t\t\t\t\t\t | | \n");
        printf(" \t\t\t\t\t\t| PALESTRA DIREITOS HUMANOS |\n");
        printf(" \t\t\t\t\t\t| | \n");
        printf(" \t\t\t\t\t\t+ ====================================== ============================ + ");
        printf("escolha ");
        // Chama função para validar a senha
        verifica_senha = valida_senha ();
        printf("\nverifica senha %d\n", verifica_senha);
        printf("opcaomp = % d\n", opcaomp);
        if (verifica_senha == 1)
        {
            opcaomp = 0;

            // Setar todos os assentos como livres
            for (j = 0; j < 52; j++)
            {
                status[j] = 0;    // 0 - Assento livre -> 1 - Assento ocupado
            }


            // Apresenta a tela de menu principal
            while (opcaomp != 4)
            {
                verifica_senha = 1;
                cls
                printf("  \n\n\n\n\n\n\t\t\t\t\t\t+======================== ============================================== + ");
                printf(" \n \t \t \t \t \t \t | | \n ");
                printf(" \t \t \t \t \t \t | UNIP - UNIVERSIDADE PAULISTA | \n ");
                printf(" \t \t \t \t \t \t | | \n ");
                printf(" \t \t \t \t \t \t | | \n ");
                printf(" \t \t \t \t \t \t | **** MENU PRINCIPAL **** | \n ");
                printf(" \t \t \t \t \t \t | | \n ");
                printf(" \t \t \t \t \t \t | 1 - Gerenciar Visitante | \n ");
                printf(" \t \t \t \t \t \t | | \n ");
                printf(" \t \t \t \t \t \t | 2 - Realizar Sorteio | \n ");
                printf(" \t \t \t \t \t \t | | \n ");
                printf(" \t \t \t \t \t \t | 3 - Enviar Comunicado por E-mail | \n ");
                printf(" \t \t \t \t \t \t | | \n ");
                printf(" \t \t \t \t \t \t | 4 - Sair | \n ");
                printf(" \t \t \t \t  \t \t| | \n ");
                printf(" \t \t \t \t \t \t | | \n ");
                printf(" \t \t \t \t \t \t + ====================================== ============================== + \n \n ");
                printf(" \t \t \t \t \t \t                   Digite a opção desejada ......: ");
                fgets(ax, 10, stdin);
                opcaomp = atoi(ax);
                switch (opcaomp)
                {

                case  1:
                    gerenciar_visitante();
                    break;

                case  2:
                    realizar_sorteio();
                    break;

                case  3:
                    enviar_email();
                    break;

                case  4:
                    printf("\n\n\tSaindo Do Program . . . !\n\n\n");
                    sair
                default:
                    printf(" \n \t \t \t \t \t \t \t \t *** Opção Inválida! *** ");
                    getchar();

                } // Switch
            } // while (opcaomp! = 4)
        } // se (verifica_senha == 1)

    } while (t != 3 && verifica_senha == 0);

} // Main

// Função Valida Senha e Usuario

int  valida_senha()
{
    int i,ac, u,l2,c2,ret=0;
    char c;
    char l;
    u = 0;
    i = 0;
    l = 'p';
    printf("\naqui na verifica senha\n");
    printf("digite enter para terminar\n");
    printf(" \n\n\t\t\t\t\t\t  USUÁRIO .........: ");
    while ( ( ac = getch() ) != 13 )
    {
        if (ac == 13)printf("barra ene !\n");
        login[u] = (char)ac;
        printf(" *");
        u++;
    }
    login[u] = '\0';
    printf("\nlogin= %s\n",login);
    printf("digite enter para terminar\n");
    printf(" \n\n\t\t\t\t\t\t  SENHA ...........: ");
    while(  ( ac = getch() )  != 13 )
    {
        senha[i] = (char)ac;
        i++;
        printf(" *");
    }
    senha[i] = '\0';
    printf("\nsenha= %s\n",senha);
    i = 0;
    u = 0;
    l2 = strcmp(login, "adm");
    c2 = strcmp(senha, "123");
    printf("\n    Tecle \n");
    if (c2 != 0 || l2 != 0 ) // Senha e usuario Inválida
    {
        printf(" \n \n \t \t \t \t \t *** Senha ou Usúario inválido! Tente novamente *** \n \n ");
        t = t + 1;
        system(" cor 0c ");
        getchar();
    }
    else // Senha e Usuario Correta
    {
        printf("login e senha corretos\n");
        verifica_user = 1;
        verifica_senha = 1;
        ret = 1;
        printf("    Tecle \n");
        getch();
    }
    if (t == 3)
    {
        // sistema ("cls");
        printf(" \n \n \t \t \t \t \t *** Acesso Negado! *** \n \n ");
        getchar();
    }
    return ret;
} // Fim da Função Valida Senha e Usuario

// Função Gerenciar Visitante

void  gerenciar_visitante()
{

    int j, op;
    j = 0;
    op = 1;

    while (op != 5)
    {
        system(" cls ");
        printf(" \n \n \n \n \n \n \t \t \t \t \t \t + ======================== ============================================== + ");
        printf(" \n \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | UNIP - UNIVERSIDADE PAULISTA | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | 1 - Incluir Participante | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | 2 - Excluir Participante | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | 3 - Listar Lugares Livres | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | 4 - Mostrar Todos os Lugares | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | 5 - Retornar ao Menu Principal | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t + ====================================== ============================== + \n \n ");
        printf(" \t \t \t \t \t \t                   Digite a opção desejada ......: ");
        scanf("%d ", &op);

        switch (op)
        {
        case  1:   // Incluir o participante
            incluir();
            break;

        case  2:
            excluir();
            break;

        case  3:
            listar_livres();
            break;

        case  4:
            listar_todos();
            break;

        case  5:
            break;

        default:
            printf(" \n \t \t \t \t \t \t \t \t *** Opção Inválida! *** ");
            getchar();
            break;

        } // Switch
    } // enquanto (opcao! = 5)
} // Fim da Função Gerenciar Visitante

// Função incluir participantes

void  incluir()
{
    static  int linha;

    int j, encontrou, tc, i, v;
    linha = 0;
    v = 0;
    i = 0;
    do {

        encontrou = 0;
        tc = 0;

        // Mostrar tela para digitação das informações do participante

        system(" clear ");
        printf(" \n \n \n \n \n \n \t \t \t \t \t \t \t *** Cadastro de Participantes *** \n \n \n ");
        printf(" \n \t \t \t \t \t \t Nome ................................ ...: ");
        fflush(stdin);
        scanf("%[^\n]s%*c", nome[linha]);


        printf(" \n \t \t \t \t \t \t Número do CPF ..........................: ");
        scanf("%d ", &cpf[linha]);
        printf(" \n \t \t  \t \t \t \t Data de nascimento .....................: ");
        scanf("%d ", &datanasc[linha]);
        printf(" \n \t \t \t \t \t \t E-mail .............................. ...: ");
        fflush(stdin);
        scanf("%[^\n]s%*c", email[linha]);
        printf(" \n \t \t \t \t \t \t É convidado do palestrante (S / N)? .....: ");
        scanf("%[^\n]s%*c", convidado[linha]);
        printf(" \n \t \t \t \t \t \t Necessita de lugar especial (S / N)? ....: ");
        scanf("%[^\n]s%*c", especial[linha]);

        // Verifica assentos reservados e reserva assento disponível

        system(" clear ");

        // Assento Especial
        tc = strcmp(especial[linha], " S ");
        if (tc == 0)
        {
            for (j = 0; j < 3; j++)
            {
                if (status[j] == 0)
                {
                    printf(" \n \n \n \n \n \n \t \t \t \t \t \t Olá %s ", nome[linha]);
                    printf(" \n \n \t \t \t \t \t \t Seu assento é número: % d ", j + 1);
                    printf(" \n \n \t \t \t \t \t \t Esperamos que aproveite a Paletra !!! ");
                    status[j] = 1;
                    cpf[j] = cpf[linha];
                    getchar();
                    j = 3;
                    encontrou = 1;
                    op = 0;
                }
            }
        }

        //outro
        {
            // Convidado do Palestrante
            tc = strcmp(convidado[linha], " S ");
            if (tc == 0)
            {
                for (j = 3; j < 13; j++)
                {
                    if (status[j] == 0)
                    {
                        printf(" \n \n \n \n \n \n \t \t \t \t \t \t Olá %s ", nome[linha]);
                        printf(" \n \n \t \t \t \t \t \t Seu assento é número: % d ", j + 1);
                        printf(" \n \n \t \t \t \t \t \t Esperamos que aproveite a Paletra !!! ");
                        status[j] = 1;
                        cpf[j] = cpf[linha];
                        getchar();
                        j = 14;
                        encontrou = 1;
                        op = 0;
                    }
                }
            }
            //outro
            {

                // Participante

                for (j = 13; j < 52; j++)
                {
                    // i = pt [j];
                    if (status[j] == 0)
                    {
                        printf(" \n \n \n \n \n \n \t \t \t \t \t \t Olá %s ", nome[linha]);
                        printf(" \n \n \t \t \t \t \t \t Seu assento é número: % d ", j + 1);
                        printf(" \n \n \t \t \t \t \t \t Esperamos que aproveite a Paletra !!! ");
                        cpf[j] = cpf[linha];
                        status[j] = 1;
                        getchar();
                        j = 53;
                        encontrou = 1;
                        op = 0;
                    }
                }
            }

        }
        if (encontrou == 0)
        {
            printf(" *** Todos os assentos estão ocupados! *** ");
            getchar();
        }

        linha++;
        printf(" % d  % d ", cpf[linha], linha);
    } while (op == 1);
} // Fim da função incluir

// Excluir participante liberando o assento
void  excluir()
{
    int cpfPesquisa;
    int i;

    system(" clear ");
    printf(" \n \n \n \n \n \n \t \t \t \t \t \t \t Informe o CPF do participante que deseja excluir: ");
    scanf("%d", &cpfPesquisa);
    for (i = 0; i < SIZE; i++)
    {
        if (cpf[i] == cpfPesquisa)
        {
            status[i] = 0;
            cpf[i] = 0;
            datanasc[i] = 0;
            i = 54;
            printf(" \n \n \n \t \t \t \t \t \t \t *** Registro excluído com sucesso! *** ");
            getchar();
        }
    }
} // Fim da função excluir participante


// Função Listar lugares livres no auditório

void  listar_livres()
{
    int j;

    system(" clear ");
    printf(" \n \n \n \n \n \n \t \t \t \t \t \t \t *** Lugares Livres *** \n \n \n ");
    encontrou = 0;  // Bandeira para saber se existe pelo menos um assento livre

    printf(" \n \n \n \t \t \t \t \t \t Assentos Especiais \n \n ");
    printf(" \t \t \t \t \t \t Fileira A ");
    for (j = 0; j < 3; j++)
    {
        if (status[j] == 0)
        {
            printf("%d", j + 1);
            encontrou = 1;
        }
    }

    printf(" \n \n \n \t \t \t \t \t \t Assentos para Convidados do Palestrante \n \n ");
    printf(" \t \t \t \t \t \t Fileira B ");
    for (j = 3; j < 13; j++)
    {
        if (status[j] == 0)
        {
            printf("%d", j + 1);
            encontrou = 1;
        }
    }

    printf(" \n \n \n \t \t \t \t \t \t Assentos para Participantes \n \n ");
    printf(" \t \t \t \t \t \t Fileira C ");
    for (j = 13; j < 23; j++)
    {
        if (status[j] == 0)
        {
            printf("%d", j + 1);
            encontrou = 1;
        }
    }

    printf("\n");
    printf(" \t \t \t \t \t \t Fileira D ");
    for (j = 23; j < 33; j++)
    {
        if (status[j] == 0)
        {
            printf("% d", j + 1);
            encontrou = 1;
        }
    }

    printf(" \n ");
    printf(" \t \t \t \t \t \t Fileira E ");
    for (j = 33; j < 43; j++)
    {
        if (status[j] == 0)
        {
            printf("%d", j + 1);
            encontrou = 1;
        }
    }

    printf("\n");
    printf(" \t \t \t \t \t \t Fileira F ");
    for (j = 43; j < 53; j++)
    {
        if (status[j] == 0)
        {
            printf("%d", j + 1);
            encontrou = 1;
        }
    }

    getchar();
}

// Função Lista todos os lugares do auditório

void  listar_todos()
{
    int j;
    system(" clear ");

    printf(" \n \n \n \n \t \t \t \t \t \t \t      Todos os Lugares     \n ");
    printf(" \t \t \t \t \t \t + ====================================== ============================ + ");
    encontrou = 0;  // Bandeira para saber se existe pelo menos um assento livre
    printf(" \n \t \t \t \t \t \t \t   *** Livres ***   \n ");
    printf(" \n \n \t \t \t \t \t \t Assentos Especiais \n ");
    printf(" \t \t  \t \t \t \t A ");
    for (j = 0; j < 3; j++)
    {
        if (status[j] == 0)
        {
            printf("%d", j + 1);
            encontrou = 1;
        }
    }

    printf(" \n \n \n \t \t \t \t \t \t Convidados do Palestrante \n ");
    printf(" \t \t \t \t \t \t B ");
    for (j = 3; j < 13; j++)
    {
        if (status[j] == 0)
        {
            printf("% d", j + 1);
            encontrou = 1;
        }
    }

    printf(" \n \n \n \t \t \t \t \t \t Participantes \n ");
    printf(" \t \t \t \t \t \t C ");
    for (j = 13; j < 23; j++)
    {
        if (status[j] == 0)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 1;
        }
    }

    printf(" \n ");
    printf(" \t \t \t \t \t \t D ");
    for (j = 23; j < 33; j++)
    {
        if (status[j] == 0)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 1;
        }
    }
    printf(" \n ");
    printf(" \t \t \t \t \t \t E ");
    for (j = 33; j < 43; j++)
    {
        if (status[j] == 0)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 1;
        }
    }

    printf(" \n ");
    printf(" \t \t \t \t \t \t F ");
    for (j = 43; j < 53; j++)
    {
        if (status[j] == 0)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 1;
        }
    }

    // função para ver todos os ocupados
    printf(" \n \n \n \t \t \t \t \t \t + ============================== ========================= + ");
    encontrou = 0;  // Bandeira para saber se existe pelo menos um assento livre
    printf(" \n \t \t \t \t \t \t \t   *** Ocupados ***   \n ");
    printf(" \n \t \t \t \t \t \t Assentos Especiais \n ");
    printf(" \t \t \t \t \t \t A ");
    for (j = 0; j < 3; j++)
    {
        if (status[j] == 1)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 0;
        }
    }

    printf(" \n \n \n \t \t \t \t \t \t Convidados do Palestrante \n ");
    printf(" \t \t \t \t \t \t B ");
    for (j = 3; j < 13; j++)
    {
        if (status[j] == 1)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 0;
        }
    }

    printf(" \n \n \n \t \t \t \t \t \t Participantes \n ");
    printf(" \t \t \t \t \t \t C ");
    for (j = 13; j < 23; j++)
    {
        if (status[j] == 1)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 1;
        }
    }

    printf(" \n ");
    printf(" \t \t \t \t \t \t D ");
    for (j = 23; j < 33; j++)
    {
        if (status[j] == 1)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 1;
        }
    }

    printf(" \n ");
    printf(" \t \t \t \t \t \t E ");
    for (j = 33; j < 43; j++)
    {
        if (status[j] == 1)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 1;
        }
    }

    printf(" \n ");
    printf(" \t \t \t \t \t \t F ");
    for (j = 43; j < 53; j++)
    {
        if (status[j] == 1)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 1;
        }
    }

    getchar();

}


void enviar_email()   // erro nessa parte 
{

    int opM;
    opM = 1;

    while (opM != 3)
    {
        system(" clear ");
        printf(" \n \n \n \n \n \n \t \t \t \t \t \t + ======================== ============================================== + ");
        printf(" \n \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | UNIP - UNIVERSIDADE PAULISTA | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | 1 - Todos os Visitantes | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | 2 - Escolher Visitante | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | 3 - Retornar ao Menu Principal | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t + ====================================== ============================== + \n \n ");
        printf(" \t \t \t \t \t \t                   Digite a opção desejada ......: ");
        scanf("%d ", &opM);

        switch (opM)
        {

        case  1:
            email_todos();
            break;

        case  2:
            email_um();
            break;

        case  3:
            break;

        default:
            printf(" \n \t \t \t \t \t \t \t \t *** Opção Inválida! *** ");
            getchar();
        }
    }
}

void  email_todos()
{

    system(" cls ");
    printf(" \n \n \n \n \n \n \t \t \t \t \t \t + ======================== ============================================== + ");
    printf(" \n \t \t \t \t \t \t | | \n ");
    printf(" \t \t \t \t \t \t | Palestra Direito Humanos | \n ");
    printf(" \t \t \t \t \t \t | Dr. Ramiro | \n ");
    printf(" \t \t \t \t \t \t | Contéudo da Palestra: Direitos Humanos | \n ");
    printf(" \t \t \t \t \t \t | Motivo: Informativo | \n ");
    printf(" \t \t \t \t \t \t | Data: 25/12/2020 Horário: 18:30 | \n ");
    printf(" \t \t \t \t \t \t | Local: Unip - Chácara Santo Antônio | \n ");
    printf(" \t \t \t \t \t \t | | \n ");
    printf(" \t \t \t \t \t \t | Resumo | \n ");
    printf(" \t \t \t \t \t \t | Hoje em dia as pessoas torcem o nariz para palavra | \n ");
    printf(" \t \t \t \t \t \t | ?? Direitos Humanos ??, pois aqui no Brasil ela sempre | \n ");
    printf(" \t \t \t \t \t \t | sempre está ligada ao crime e violência e nunca | \n ");
    printf(" \t \t \t \t \t \t | está ao lado da vítima, mas sim daquela | \n ");
    printf(" \t \t \t \t \t \t | causaram o Dano. Porém o que ninguém sabe que | \n ");
    printf(" \t \t \t \t \t \t | na década de 40 em uma reunião em paris, foram | \n ");
    printf(" \t \t  \t \t \t \t | lançados 30 artigos no rastro da segunda guerra |  \n ");
    printf(" \t \t \t \t \t \t | Mundial, pois a falta de punição contra governos | \n ");
    printf(" \t \t \t \t \t \t | autoritários, trabalho escravo, tortura, discriminação, | \n ");
    printf(" \t \t \t \t \t \t | fome e pobreza violava todos os dias a vida dos seres | \n ");
    printf(" \t \t \t \t \t \t | humanos da época. | \n ");
    printf(" \t \t \t \t \t \t | | \n ");
    printf(" \t \t \t \t \t \t + ====================================== ============================== +  \n \n ");
    getchar();
}

void  email_um()
{
    int as;
    printf(" \t \t \t \t \t \t Escolha o Assento abaixo, Assim o e-mail será enviado para pessoa que está sentada no mesmo. \n ");
    encontrou = 0;  // Bandeira para saber se existe pelo menos um assento livre
    printf(" \n \t \t \t \t \t \t Assentos Especiais \n ");
    printf(" \t \t \t \t \t \t A ");
    for (j = 0; j < 3; j++)
    {
        if (status[j] == 1)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 0;
        }
    }

    printf(" \n \n \n \t \t \t \t \t \t Convidados do Palestrante \n ");
    printf(" \t \t \t \t \t \t B ");
    for (j = 3; j < 13; j++)
    {
        if (status[j] == 1)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 0;
        }
    }

    printf("  \n \n \n \t \t \t \t \t \t Participantes \n ");
    printf(" \t \t \t \t \t \t C ");
    for (j = 13; j < 23; j++)
    {
        if (status[j] == 1)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 1;
        }
    }

    printf(" \n ");
    printf(" \t \t \t \t \t \t D ");
    for (j = 23; j < 33; j++)
    {
        if (status[j] == 1)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 1;
        }
    }

    printf("  \n");
    printf(" \t \t \t \t \t \t E ");
    for (j = 33; j < 43; j++)
    {
        if (status[j] == 1)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 1;
        }
    }

    printf(" \n ");
    printf(" \t \t \t \t \t \t F ");
    for (j = 43; j < 53; j++)
    {
        if (status[j] == 1)
        {
            printf(" [ % d ] ", j + 1);
            encontrou = 1;
        }
    }

    printf(" \n \t\t \t \t \t \t \t \t Necessário apenas o número do assento \n ");
    printf(" \t \t \t \t \t \t \t \t Assento ......: ");
    scanf(" %d ", &as);

    system(" clear ");
    if (as > 0 && as < 54) {

        printf(" \n \n \n \n ");
        printf(" \n \n \n \n \t \t \t \t \t \t Assento: % d  \n ", as);
        printf(" \t \t \t \t \t \t Email Enviado com Sucesso !!! \n \n ");
        printf(" \t \t \t \t \t \t Conteúdo: \n ");
        printf(" \t \t \t \t \t \t + ====================================== ============================== + ");
        printf(" \n \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | Palestra Direito Humanos | \n ");
        printf(" \t \t \t \t \t \t | Dr. Ramiro | \n ");
        printf(" \t \t \t \t \t \t | Contéudo da Palestra: Direitos Humanos | \n ");
        printf(" \t \t \t \t \t \t | Solicitação do Assento: % d                                | \n ", as);
        printf(" \t \t \t \t \t \t | Motivo: Para Envio do Informativo | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | Data: 13/12/2018 Horário: 18:30 | \n ");
        printf(" \t \t \t \t \t \t | Local: Unip - Chácara Santo Antônio | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t | Resumo | \n ");
        printf(" \t \t \t \t \t \t | Hoje em dia as pessoas torcem o nariz para palavra | \n ");
        printf(" \t \t \t \t \t \t | ?? Direitos Humanos ??, pois aqui no Brasil ela sempre | \n ");
        printf(" \t \t \t \t \t \t | sempre está ligada ao crime e violência e nunca | \n ");
        printf(" \t \t \t \t \t \t | está ao lado da vítima, mas sim daquela | \n ");
        printf(" \t \t \t \t \t \t | causaram o Dano. Porém o que ninguém sabe que | \n ");
        printf(" \t \t \t \t \t \t | na década de 40 em uma reunião em paris, foram | \n ");
        printf(" \t \t \t \t \t \t | lançados 30 artigos no rastro da segunda guerra | \n ");
        printf(" \t \t \t \t \t \t | Mundial, pois a falta de punição contra governos | \n ");
        printf(" \t \t \t \t \t \t | autoritários, trabalho escravo, tortura, discriminação, | \n ");
        printf(" \t \t \t \t \t \t | fome e pobreza violava todos os dias a vida dos seres | \n ");
        printf(" \t  \t \t \t \t \t | humanos da época. | \n ");
        printf(" \t \t \t \t \t \t | | \n ");
        printf(" \t \t \t \t \t \t + ====================================== ============================== + \n \n ");

        getchar();

    }
    else {
        printf(" \t \t \t \t \t \t Assento Inválido \n ");
        getchar();
    }
    getchar();

}

void  realizar_sorteio()
{
    srand(time(NULL)); // escolhe sequencia de numeros aleatorios
    int valores[] = { 1 , 2 , 3 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 34 , 35 , 36 , 37 ,38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , 48 , 49 , 50 , 51 , 52 , 53 };
    int n = sizeof valores / sizeof * valores;
    n = rand() % 53;
    printf(" \t \t \t \t \t \t \t \t + ================================== == + \n ");
    printf(" \t \t \t \t \t \t \t \t PARABÉNS !!!! \n ");
    printf(" \t \t \t \t \t \t \t \t *** Assento: % d *** \n ", valores[rand() % n]);
    printf(" \t  \t \t \t \t \t \t \t Você foi Sorteado !!!!! ");
    getchar();
}

 

  • Curtir 1
Link para o comentário
Compartilhar em outros sites

Seu programa não está nada bom :( 

São quase 900 linhas de grande dificuldade para manter e mesmo para chegar até onde chegou, imagino.

 

O maior problema pode ser visto logo nas primeiras 50 linhas: 

  • todas as variáveis são globais
  • todas as funções retornam void
  • nenhuma das funções tem argumentos. Mesmo a pobre main() foi privada dos tradicionais dois argumentos a que todo programa tem direito, argc e argv.

Isso por si só já condena você a um ciclo de grandes dificuldades.

 

Tem muitas outras coisas que eu poderia te recomendar, mas em especial:

 

Sobre scanf()

  • não use scanf() para ler do teclado. Não foi escrita para isso. Se vai MESMO insistir --- não insista --- entenda que DEVE testar SEMPRE o retorno de scanf(). Imagino que tenha um livro ou um manual ou uma apostila ou alguém em que confie e que tenha escrito mais de um programa nessa linguagem. Leu algo sobre scanf()? Como começou a usar?
     
  • Ela retorna um int com o total de valores lidos... Está no livro, no manual, na apostila...
     
  • Usa um IDE? Ele não mostra os parâmetros das funções? Algo assim como esse no openSUSE Linux usando VS Code
    image.png.0cc85915d0bb6c406fb34e4d8f7fce4e.pngEm geral num IDE moderno, ao parar o cursor sobre a função como no exemplo a direita --- que é o seu programa chamando scanf() para ler  login --- aparecem os parâmetros das funções. E em alguns casos até uma descrição dos parâmetros e um resumo do que ela faz, mesmo que seja uma função do seu programa, tipo listar_livres(). 
     
  • O que é login? Pois é: um IDE moderno não deixa você em dúvida:

    image.png.51ecb063422fa50d68f5a8e42d26f2d9.pnglogin é char[10]. E está lendo --- sem testar o retorno --- com o especificador %c que lê uma única letra. Claro que não leu nada.
  • Está lendo usando a função errada com o especificador errado e, sem testar se leu algo, simplesmente passa adiante e tenta ler a senha. Eu não ficaria surpreso se desse errado. E deu errado. Use por exemplo 
     
    	fgets( login, sizeof(login), stdin );


    e terá uma vida mais tranquila. Leia o manual sobre fgets().

    Se está aprendendo talvez possa ser menos confiante e ao menos mostrar o que leu na tela antes de seguir. Algo assim já serviria 
     

        printf("Usuario: " );
        fgets(login, sizeof(login), stdin);
        puts(login);
        fgetc(stdin);

     

E teria mostrado que leu login. Ao ler o manual vai ver que fgets() lê até o enter, e deixa o ENTER na string lida. Se vai usar em comparações ou outras funções exclua o último valor da string lida. Não requer muita especialização: a última posição de qualquer string é claro o tamanho dela menos 1, já que a primeira posição é zero. E o tamanho atual dela é dado por strlen().  E as strings em C terminam por zero, como deve também já saber. Então bastaria escrever
 

        login[strlen[login] - 1 = 0;


e teria a string apenas com o valor. Completando o exemplo acima então:
 

    printf("Usuario: " );
    fgets(login, sizeof(login), stdin);
    puts(login); // mostra como leu: vai pular uma linha
    login[ strlen(login) -1 ] = 0; // apaga o enter
    printf("Valor de login: '%s'\n", login); // mostra entre ' '
    fgetc(stdin); // espera pra ler

 

Para um usuário "Livro" mostraria
 

Usuario: Livro
Livro

Valor de login: 'Livro'

 

Isso explica porque não passou sequer do login.

 

As telas

 

Entenda que essas coisas são um pesadelo:
 

  system ( " clear " );
   
    printf ( " \n\n\n\n\n\n\n\t\t\t\t\t\t + ======================== ============================================ + " );
    printf ( " \n\t\t\t\t\t\t | | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxx xxxx  xxxx     xxxx xxxx xxxxxxxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxx xxxx  xxxxxx   xxxx xxxx xxxx xxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxx xxxx  xxxx xx  xxxx xxxx xxxx xxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxx xxxx  xxxx  xx xxxx xxxx xxxxxxxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxxxxxxx  xxxx   xxxxxx xxxx xxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxxxxxxx  xxxx    xxxxx xxxx xxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | | \n " );
    printf ( " \t\t\t\t\t\t\t | | \n " );
    printf ( "\t\t\t\t\t\t\t\t| UNIVERSIDADE PAULISTA | \n " );
    printf ( "\t\t\t\t\t\t | | \n " );
    printf ( " \t\t\t\t\t\t | | \n" );
    printf ( " \t\t\t\t\t\t| PALESTRA DIREITOS HUMANOS |\n");
    printf ( " \t\t\t\t\t\t| | \n" );
    printf ( " \t\t\t\t\t\t+ ====================================== ============================ + " );
    printf ( " \n\n\t\t\t\t\t\t  USUÁRIO .........: " );

 

Sete TAB? E alinhar isso demora uma eternidade. E não leva a nada. Isso podia estar no disco em texto01de20.txt ;) 
 

+ ================================================================== +
            |                                         |               
            |                                         |               
            | xxxx xxxx  xxxx     xxxx xxxx xxxxxxxxx |
            | xxxx xxxx  xxxxxx   xxxx xxxx xxxx xxxx | 
            | xxxx xxxx  xxxx xx  xxxx xxxx xxxx xxxx | 
            | xxxx xxxx  xxxx  xx xxxx xxxx xxxxxxxxx |
            | xxxxxxxxx  xxxx   xxxxxx xxxx xxxx      |
            | xxxxxxxxx  xxxx    xxxxx xxxx xxxx      |
            |                                         |
            |                                         |
            | UNIVERSIDADE PAULISTA                   |
            |                                         |
            |                                         |
            |               PALESTRA DIREITOS HUMANOS |
            |                                         |
+ ================================================================== +


  USUÁRIO .........: 


e a mesma função que mostrasse um mostraria todos:
 

        int menu(const char* arquivo);


Faça o simples
 

Não misture lógica com formatação. Separe seus dados. Escreva em torno dos dados.

 

Se quer mesmo uma coisa assim EDITE um arquivo TXT com o que quer mostrar, abra o arquivo e mostre as linhas todas. Dá umas 6 linhas de programa e funciona para qualquer texto. Você usou 15 e só funciona para esse pedaço do programa. E só uma vez.  Se estivesse em arquivo poderia alinhar direto no IDE. Sem stress. Mudar para italiano, mudar o texto...

 

fflush()

 

Esqueça isso. fflush() só está definido para arquivos de saída. E quando precisar disso você vai saber.

 

scanf()
 

Leia sempre o valor de retorno. Essas são as chamadas a scanf() em seu programa. Nunca testou, claro. Não acha que seria razoável testar se leu algo?

 

74:    scanf("%c", senha);
115:            scanf ( "%d " , & opcaomp);
223:       scanf ( "%d " , &op);
275:       scanf("%[^\n]s%*c",nome[linha]);
279:       scanf ( "%d " , & cpf [linha]);
281:       scanf ( "%d " , & datanasc [linha]);
284:       scanf ("%[^\n]s%*c", email[linha]);
286:       scanf( "%[^\n]s%*c" , convidado[linha]);
288:       scanf( "%[^\n]s%*c", especial[linha]);
380:    scanf ( "%d" , & cpfPesquisa);
649:       scanf ( "%d " , &opM);
775:    scanf ( " %d " , &as);

 

Não use esses especificadores complicados se está começando a programar com isso. Nunca use a menos que tenha experiência e convicção do que está querendo ler. Alguns tem efeitos colaterais, como o espaço depois do especificador e o asterisco, no caso de seu programa. E alguns estão só errados mesmo como esses que misturam colchetes e %s nas linhas 284, 286 e outras.

 

Na dúvida escreva um  programa de 10 linhas e teste. Não deixe em um programa de 1000 linhas para ver o que acontece depois.

 

 Mais algumas coisas para você considerar: 
 

image.png.2e56f113ff29a986cd7583aa0973f743.png

 

O que fez você imaginar que poderia trocar o label do case de default para padrão? 
 

  • Não use acentos em seu programa. Em variáveis, em strings ou em comentários, a menos que o enunciado exija. Não vai aprender nada e só vai ter problemas. O mesmo vale para cores, animações e efeitos. Faça o programa funcionar. Teste tudo e depois enfeite.
     
  • Não use system() para nada. Não estará fazendo nada. Não há nada que possa fazer com system() que não possa fazer em C ou C++. system() foi escrita em C e o sistema quase todo também. E em geral é proibido em empresas e escolas afinal: é um risco grande de segurança
     
  • evite retornar void: em geral é um desperdício. Muitas vezes um erro.
     
  • Use alguma ordem em suas funções, como a ordem alfabética por exemplo. Vai gostar disso quando seu programa tiver 50 funções ao invés de umas poucas. Muitos IDE mostram uma lista das funções, em geral na ordem em que foram declaradas, de modo que você pode clicar no nome e o editor vai direto para o código. E se estiverem em ordem é claro que você só ganha.
     
  • Nunca leia valores do teclado para alimentar seu programa antes dele estar rodando. Só vai te atrasar e não acrescenta absolutamente nada. Use constantes, use funções que retornam a estrutura preenchida. Ao terminar os  testes aí sim incorpore a leitura

Escreva seu programa em torno dos dados e não em torno das telas. Não misture as coisas. 

 

 

 

image.png

  • Obrigado 2
Link para o comentário
Compartilhar em outros sites

@Murilo Murilo então não entendeu mesmo o que expliquei sobre o login, o char[10], o %c?, scanf(), Nada? Rodou o trecho do exemplo progressivo que te mostrei? Qual o seu plano para o login? vai deixar usuários e senhas fixos dentro do programa? Precisa resolver essas coisas antes de começar a escrever o programa.

 

Eu te mostrei claramente como ler a senha, por exemplo. Não entendeu aquilo? Nada perguntou

  • Curtir 3
Link para o comentário
Compartilhar em outros sites

@Murilo Murilo você deveria começar a fazer do zero o programa, é focando nas partes que você tem mais dificuldade.

 

Exemplo de login simples.

Spoiler

/* Login simples */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

/* Constantes */
#define T_NOME 30
#define T_SENHA 20

/* Definições */
struct info_login
{
    char nome[T_NOME];
    char senha[T_SENHA];
};


void
pegaLogin(struct info_login *l);

int main(void)
{
    struct info_login usuario, temporario;
    printf("\nCadastre um usuario e senha\n");
    pegaLogin(&temporario);
    do {
        printf("\nFaca o login no sistema\n ");
        pegaLogin(&usuario);
        if (!(strcmp(temporario.nome, usuario.nome) == 0 && strcmp(temporario.senha, usuario.senha) == 0)) {
            printf("\nUsuario ou senha invalidos!\n");
        }
    } while (!(strcmp(temporario.nome, usuario.nome) == 0 && strcmp(temporario.senha, usuario.senha) == 0));
    printf("\nUsuario logado!");
    getchar();      /* Pausa o programa */
    return(0);
}

void
pegaLogin(struct info_login *l)
{
    printf("\nDigite o nome de usuario:\t");
    fgets(l->nome, T_NOME, stdin);
    printf("\nDigite a senha de usuario:\t");
    fgets(l->senha, T_SENHA, stdin);
}

 

 

  • Curtir 2
Link para o comentário
Compartilhar em outros sites

@arfneto  eu entendi o que disse sobre o codigo , ja alterei o login mas nao consigo fazer o sistema validar  , ja usei o que o amigo acima ai disse mas nao consegui   ,  eu queria conseguir pelo menos fazer ele passar do login para min conseguir partir para outro passo é um trabalho de faculdade isso entendeu ?

  • Obrigado 1
Link para o comentário
Compartilhar em outros sites

Usando sua função valida_senha() como exemplo, vou tentar te explicar o que está errado com essa técnica que usou. Entenda que pode muito bem funcionar do modo como está fazendo, apenas não vale a pena fazer assim:

  • Não vai aprender quase nada
  •  Não vai servir para usar depois
  • Vai dar um trabalho enorme
  • Vai demorar uma era ou duas

Criando uma alternativa

Passo 1:

é preciso pensar nos dados e escrever em torno dos dados --- Isso se acreditar no que estou falando, claro.
valida_senha() tem uma função menor no programa, local. E não poderia interferir em nada. Se está interferindo é porque algo está errado na construção do programa em si.

Passo 2:

num novo arquivo, copiei só valida_senha(). fazendo.c é o nome que usei.

O conteúdo:
 

Spoiler


#include <stdio.h>
#include <string.h>

void  valida_senha ()
{
    int i, u;
    char c;
    char l;
    u = 0 ;
    i = 0 ;
    while ((c = getchar ()) != 13 )
    {
       senha [i] = c;
       login [u] = l;
       u ++;
       i ++;
       printf ( " * " );
    }

    login [u] =  0  ;
    senha [i] =  0 ;
    i = 0 ;
    u = 0 ;
    l = strcmp (login, " adm " );
    c = strcmp (senha, " 1 " );

    if (c == 1 && l == 1 ) // Senha e usuario Inválida
    {
        printf ( " \n \n \t \t \t \t \t *** Senha ou Usúario inválido! Tente novamente *** \n \n " );
        t = t + 1 ;
        system ( " cor 0c " );
        getchar ();
    }
    else // Senha e Usuario Correta
    {
        verifica_user = 1 ;
        verifica_senha = 1 ;
    }
    if (t == 3 )
    {
      // sistema ("cls");
      printf ( " \n \n \t \t \t \t \t *** Acesso Negado! *** \n \n " );
      getchar (); 
    }
} // Fim da Função Valida Senha e Usuario

 


E tentei compilar. O simples, com
 

        cc -c fazendo.c


E o compilador se queixou de 4 variáveis, as tais globais que você NUNCA deve usar. Veja que o compilador já diz o que está errado, e não é novidade alguma:
 

image.png.6ba717145aaffbfa1771e7a9b46df770.png

É claro, senha está definida como global em main(). O mesmo caso das outras 3

 

 

    // de main()

int verifica_senha = 0 ;
int verifica_user = 0 ;
char login [ 10 ];
char senha [ 8 ];

    // de main()

 

 São essas. E agora reclamou de system() e de 't'. Não tem o menor sentido existir uma variável global com o nome genial de uma única letra. Não acreditei. Mas assim você fez.

Sobre system() eu já falei antes: apenas não use. É um erro. Este é um programa em C. Essa linguagem foi escrita para escrever um sistema, o próprio Unix. E foi depois copiado por Linus Torvalds sem qualquer cerimônia ao escrever o Linux. Isso quer dizer que system() foi escrito em C e o próprio sistema foi escrito em C e não há praticamente nada que não possa fazer em C em Linux. E se tem você provavelmente não deveria fazer mesmo ;)


Corrigindo isso agora o programa compila assim:
 

Spoiler


#include <stdio.h>
#include <string.h>

void  valida_senha ()
{
    // de main()

int verifica_senha = 0 ;
int verifica_user = 0 ;
char login [ 10 ];
char senha [ 8 ];

    // de main()
    int t = 0;
    int i, u;
    char c;
    char l;
    u = 0 ;
    i = 0 ;
    while ((c = getchar ()) != 13 )
    {
       senha [i] = c;
       login [u] = l;
       u ++;
       i ++;
       printf ( " * " );
    }

    login [u] =  0  ;
    senha [i] =  0 ;
    i = 0 ;
    u = 0 ;
    l = strcmp (login, " adm " );
    c = strcmp (senha, " 1 " );

    if (c == 1 && l == 1 ) // Senha e usuario Inválida
    {
        printf ( " \n \n \t \t \t \t \t *** Senha ou Usúario inválido! Tente novamente *** \n \n " );
        t = t + 1 ;
        getchar ();
    }
    else // Senha e Usuario Correta
    {
        verifica_user = 1 ;
        verifica_senha = 1 ;
    }
    if (t == 3 )
    {
      // sistema ("cls");
      printf ( " \n \n \t \t \t \t \t *** Acesso Negado! *** \n \n " );
      getchar (); 
    }
} // Fim da Função Valida Senha e Usuario

 

 

Não serve para nada por enquanto. Trata-se de uma prova de conceito.

 

Passo 3:
 

Agora vamos usar essa função em main() como se faz no mundo real na prática: ela já compila. Em fazenda.h tem uma função valida_senha(). Criado um novo arquivo fazenda.h com 3 linhas
 

// fazendo.h
void        valida_senha();
// fim

 

Agora editando seu programa apagamos valida_senha() todinha e a declaração dela. E depois dos include todos colocamos 
 

#include "fazendo.h"


E podemos criar o programa de novo, desta vez com o comando
 

    cc murilo.c fazenda.c


E claro que ele vai estar igual.
 

Mas está diferente também.

 

Passo 4:

 

Agora que temos algo mais controlado, vamos arrumar valida_senha(). Eis a realidade dessa função:
 

int         valida_senha(const char* login, const char* senha)

 

Essa função recebe duas strings, login e senha, e retorna um int. O simples: 0 se a senha está errada. Ou o usuário, ou  o presidente da república, não importa. Se está errado retorna 0. 

 

E ela não depende de mais nada externo. E nada externo interfere aqui, como a variável 't'. Espero que tenha entendido já porque isso é importante.

 

Passo 5:

 

Mudamos valida_senha() para mostrar os parâmetros que recebeu e retornar ok sem testar nada. Não é importante agora: basta seguir o programa


Algo assim:
 

int         valida_senha(const char* login, const char* senha)
{
    int t = 0;
    printf("valida_senha(): login '%s' senha '%s'\n",
        login, senha);
    printf("tecle enter para retornar de valida_senha()\n ");
    fgetc(stdin);
    if ( t == 0 ) return 1;


  // ...

 

Assim fica claro para o compilador que login e senha são parâmetros de entrada, imutáveis. Vão ser processados de algum modo e se estiver ok retorna 1. Então retorna 1. Ou retorna zero. Só isso: a vida segue...

 

Passo 6:

Usando a nova versão:
 

Em main() usa o código que te mostrei antes: 
 

// ...

    printf ( " \t\t\t\t\t\t| PALESTRA DIREITOS HUMANOS |\n");
    printf ( " \t\t\t\t\t\t| | \n" );
    printf ( " \t\t\t\t\t\t+ ====================================== ============================ + " );
    fflush(stdin);
    //xx
    printf ( " \n\n\t\t\t\t\t\t  USUÁRIO .........: " );
    fgets(login, sizeof(login), stdin);
    login[strlen(login)-1] = 0;
    printf ( " \n\n\t\t\t\t\t\t  SENHA ...........: " );
    fgets(senha, sizeof(senha), stdin);
    senha[strlen(senha)-1] = 0;
    // Chama função para validar a senha
    verifica_senha = valida_senha(login,senha);

    if (verifica_senha == 1 )
    {
        opcaomp = 0 ;
      
      // ...

image.png.9371da52e073dc56782950d3606d0a2d.png

 

E então funcionou: valida_senha() recebe os parâmetros ok. Vai retornar 1 e podemos apagar esse teste na função...


Vai ficar:
 

int         valida_senha(const char* login, const char* senha)
{
    int t = 0;
    printf("valida_senha(): login '%s' senha '%s'\n",
        login, senha);
    if ( t == 0 ) return 1;

// ...

 

E sabemos que está certo. Apenas depois voltamos aqui para implementar a lógica LOCAL de verificar a senha e o login contra tabelas de usuários e senhas.

 

Resumo:

foi criado um arquivo com as funções sendo reescritas, fazendo.c

  • foi criado um header com as novas declarações: fazendo.h
  • as  funções sendo reescritas são apagadas de main(), claro
  • o header foi incluido em main() claro, para o compilador ahcar as declarações das funções movidas

Como ficaram os arquivos

 

Spoiler


# define  SIZE  53

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <time.h>

#include "fazendo.h"

// Definição das variáveis

char nome [SIZE] [ 50 ];
char email [SIZE] [ 50 ];
int datanasc [SIZE];
int cpf [SIZE];
char convidado [SIZE] [ 1 ];
char especial [SIZE] [ 1 ];
int op, t, opcaomp, encontrou;
int j;
int verifica_senha = 0 ;
int verifica_user = 0 ;
char login [ 10 ];
char senha [ 8 ];

// int status_es [3];
// int status_cv [10];
// int status_pt [40];

int status [ 53 ];

int assento [SIZE];

// Definição das variáveis de funções
void email_todos ();//corrigir erro 675;
void  incluir ();
void  excluir ();
void  listar_livres ();
void realizar_sorteio ();
void  enviar_email ();//corrigir erros629;
void email_um();//corrigir erro 705;

void  listar_todos ();//corrigir erro line480;
void  gerenciar_visitante ();//line198;

// Rotina principal

int  main (void)
{

setlocale (LC_ALL, " portuguese " );

do
{
    system ( " clear " );
   
    printf ( " \n\n\n\n\n\n\n\t\t\t\t\t\t + ======================== ============================================ + " );
    printf ( " \n\t\t\t\t\t\t | | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxx xxxx  xxxx     xxxx xxxx xxxxxxxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxx xxxx  xxxxxx   xxxx xxxx xxxx xxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxx xxxx  xxxx xx  xxxx xxxx xxxx xxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxx xxxx  xxxx  xx xxxx xxxx xxxxxxxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxxxxxxx  xxxx   xxxxxx xxxx xxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | xxxxxxxxx  xxxx    xxxxx xxxx xxxx | \n " );
    printf ( " \t\t\t\t\t\t\t | | \n " );
    printf ( " \t\t\t\t\t\t\t | | \n " );
    printf ( "\t\t\t\t\t\t\t\t| UNIVERSIDADE PAULISTA | \n " );
    printf ( "\t\t\t\t\t\t | | \n " );
    printf ( " \t\t\t\t\t\t | | \n" );
    printf ( " \t\t\t\t\t\t| PALESTRA DIREITOS HUMANOS |\n");
    printf ( " \t\t\t\t\t\t| | \n" );
    printf ( " \t\t\t\t\t\t+ ====================================== ============================ + " );
    fflush(stdin);
    //xx
    printf ( " \n\n\t\t\t\t\t\t  USUÁRIO .........: " );
    fgets(login, sizeof(login), stdin);
    login[strlen(login)-1] = 0;
    printf ( " \n\n\t\t\t\t\t\t  SENHA ...........: " );
    fgets(senha, sizeof(senha), stdin);
    senha[strlen(senha)-1] = 0;
    // Chama função para validar a senha
    verifica_senha = valida_senha(login,senha);

    if (verifica_senha == 1 )
    {
        opcaomp = 0 ;

        // Setar todos os assentos como livres
        for (j = 0 ; j < 52 ; j ++)
        {
          status [j] = 0 ;    // 0 - Assento livre -> 1 - Assento ocupado
        }


        // Apresenta a tela de menu principal

        while (opcaomp != 4 )
        {
            
            verifica_senha = 1 ;
            system ( " clear " );
            printf ( "  \n\n\n\n\n\n\t\t\t\t\t\t+======================== ============================================== + " );
            printf ( " \n \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | UNIP - UNIVERSIDADE PAULISTA | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | **** MENU PRINCIPAL **** | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | 1 - Gerenciar Visitante | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | 2 - Realizar Sorteio | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | 3 - Enviar Comunicado por E-mail | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t | 4 - Sair | \n " );
            printf ( " \t \t \t \t  \t \t| | \n " );
            printf ( " \t \t \t \t \t \t | | \n " );
            printf ( " \t \t \t \t \t \t + ====================================== ============================== + \n \n " );
            printf ( " \t \t \t \t \t \t                   Digite a opção desejada ......: " );
            scanf ( "%d " , & opcaomp);
            switch (opcaomp)
            {

                case  1 :
                    gerenciar_visitante ();
                    break ;

                case  2 :
                    realizar_sorteio ();
                    break ;

                case  3 :
                    enviar_email ();
                    break;

                case  4 :
                    system ( " exit " );
                    break ;

                default:
                    printf ( " \n \t \t \t \t \t \t \t \t *** Opção Inválida! *** " );
                    getchar ();

            } // Switch
        } // while (opcaomp! = 4)
    } // se (verifica_senha == 1)

} while (t != 3 && verifica_senha == 0 );

} // Main


// Função Gerenciar Visitante

void  gerenciar_visitante ()
{

    int j, op;

    op = 1 ;

    while (op != 5 )
    {
       system ( " cls " );
       printf ( " \n \n \n \n \n \n \t \t \t \t \t \t + ======================== ============================================== + " );
       printf ( " \n \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | UNIP - UNIVERSIDADE PAULISTA | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 1 - Incluir Participante | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 2 - Excluir Participante | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 3 - Listar Lugares Livres | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 4 - Mostrar Todos os Lugares | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 5 - Retornar ao Menu Principal | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t + ====================================== ============================== + \n \n " );
       printf ( " \t \t \t \t \t \t                   Digite a opção desejada ......: " );
       scanf ( "%d " , &op);

       switch (op)
       {
          case  1 :   // Incluir o participante
             incluir ();
            break ;

          case  2 :
             excluir ();
            break ;

          case  3 :
            listar_livres ();
            break ;

          case  4 :
            listar_todos ();
            break;

          case  5 :
           break ;

          default: 
            printf ( " \n \t \t \t \t \t \t \t \t *** Opção Inválida! *** " );
            getchar ();
            break;

       } // Switch
    } // enquanto (opcao! = 5)
} // Fim da Função Gerenciar Visitante

// Função incluir participantes

void  incluir ()
{
    static  int linha;

    int j, encontrou, tc, i, v;
    linha = 0 ;

    do {

       encontrou =0 ;
       tc =0 ;

       // Mostrar tela para digitação das informações do participante

       system ( " clear " );
       printf ( " \n \n \n \n \n \n \t \t \t \t \t \t \t *** Cadastro de Participantes *** \n \n \n " );
       printf ( " \n \t \t \t \t \t \t Nome ................................ ...: " );
       fflush (stdin);
       scanf("%[^\n]s%*c",nome[linha]);


       printf ( " \n \t \t \t \t \t \t Número do CPF ..........................: " );
       scanf ( "%d " , & cpf [linha]);
       printf ( " \n \t \t  \t \t \t \t Data de nascimento .....................: " );
       scanf ( "%d " , & datanasc [linha]);
       printf ( " \n \t \t \t \t \t \t E-mail .............................. ...: " );
       fflush (stdin);
       scanf ("%[^\n]s%*c", email[linha]);
       printf ( " \n \t \t \t \t \t \t É convidado do palestrante (S / N)? .....: " );
       scanf( "%[^\n]s%*c" , convidado[linha]);
       printf ( " \n \t \t \t \t \t \t Necessita de lugar especial (S / N)? ....: " );
       scanf( "%[^\n]s%*c", especial[linha]);

       // Verifica assentos reservados e reserva assento disponível

       system ( " clear " );

       // Assento Especial
       tc = strcmp (especial [linha], " S " );
       if (tc == 0 )
       {
        for (j = 0 ; j < 3 ; j++)
          {
           if (status [j] == 0 )
            {
               printf ( " \n \n \n \n \n \n \t \t \t \t \t \t Olá %s " , nome [linha]);
               printf ( " \n \n \t \t \t \t \t \t Seu assento é número: % d " , j + 1 );
               printf ( " \n \n \t \t \t \t \t \t Esperamos que aproveite a Paletra !!! " );
               status [j] = 1 ;
               cpf [j] = cpf [linha];
               getchar ();
               j = 3 ;
               encontrou = 1 ;
               op = 0 ;
            }
          }
       }

       //outro
       {
       // Convidado do Palestrante
       tc = strcmp (convidado [linha], " S " );
       if (tc == 0 )
       {
          for (j = 3 ; j < 13 ; j ++)
          {
            if (status [j] == 0 )
            {
               printf ( " \n \n \n \n \n \n \t \t \t \t \t \t Olá %s " , nome [linha]);
               printf ( " \n \n \t \t \t \t \t \t Seu assento é número: % d " , j + 1 );
               printf ( " \n \n \t \t \t \t \t \t Esperamos que aproveite a Paletra !!! " );
               status [j] = 1 ;
               cpf [j] = cpf [linha];
               getchar ();
               j = 14 ;
               encontrou = 1 ;
               op = 0 ;
            }
          }
       }
       //outro
       {

       // Participante

          for (j = 13 ; j < 52 ; j ++)
          {
            // i = pt [j];
            if (status [j] == 0 )
            {
               printf ( " \n \n \n \n \n \n \t \t \t \t \t \t Olá %s " , nome[linha]);
               printf ( " \n \n \t \t \t \t \t \t Seu assento é número: % d " , j + 1 );
               printf ( " \n \n \t \t \t \t \t \t Esperamos que aproveite a Paletra !!! " );
               cpf [j] = cpf [linha];
               status [j] = 1 ;
               getchar ();
               j = 53 ;
               encontrou = 1 ;
               op = 0 ;
            }
          }
       }

    }
    if (encontrou == 0 )
    {
       printf ( " *** Todos os assentos estão ocupados! *** " );
       getchar ();
    }

    linha ++;
    printf ( " % d  % d " , cpf [linha], linha);
    } while(op == 1 );
} // Fim da função incluir

// Excluir participante liberando o assento
void  excluir ()
{
    int cpfPesquisa;
    int i;

    system ( " clear " );
    printf ( " \n \n \n \n \n \n \t \t \t \t \t \t \t Informe o CPF do participante que deseja excluir: " );
    scanf ( "%d" , & cpfPesquisa);
      for (i = 0 ; i <SIZE; i++)
    {
       if (cpf [i] == cpfPesquisa)
       {
          status [i] = 0 ;
          cpf [i] = 0 ;
          datanasc [i] = 0 ;
          i = 54 ;
          printf ( " \n \n \n \t \t \t \t \t \t \t *** Registro excluído com sucesso! *** " );
          getchar ();
       }
    }
} // Fim da função excluir participante


// Função Listar lugares livres no auditório

void  listar_livres ()
{
    int j;

    system ( " clear " );
    printf ( " \n \n \n \n \n \n \t \t \t \t \t \t \t *** Lugares Livres *** \n \n \n " );
    encontrou = 0 ;  // Bandeira para saber se existe pelo menos um assento livre

    printf ( " \n \n \n \t \t \t \t \t \t Assentos Especiais \n \n " );
    printf ( " \t \t \t \t \t \t Fileira A " );
      for (j = 0 ; j < 3 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "%d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Assentos para Convidados do Palestrante \n \n " );
    printf ( " \t \t \t \t \t \t Fileira B " );
      for (j = 3 ; j < 13 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "%d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Assentos para Participantes \n \n " );
    printf ( " \t \t \t \t \t \t Fileira C " );
      for (j = 13 ; j < 23 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "%d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( "\n" );
    printf ( " \t \t \t \t \t \t Fileira D " );
      for (j = 23 ; j < 33 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "% d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t Fileira E " );
      for (j = 33 ; j < 43 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "%d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( "\n" );
    printf ( " \t \t \t \t \t \t Fileira F " );
     for (j = 43 ; j < 53 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "%d" , j + 1 );
            encontrou = 1 ;
        }
    }

    getchar ();
 }

 // Função Lista todos os lugares do auditório

void  listar_todos ()
{
    int j;
    system ( " clear " );

    printf ( " \n \n \n \n \t \t \t \t \t \t \t      Todos os Lugares     \n " );
    printf ( " \t \t \t \t \t \t + ====================================== ============================ + " );
    encontrou = 0 ;  // Bandeira para saber se existe pelo menos um assento livre
    printf ( " \n \t \t \t \t \t \t \t   *** Livres ***   \n " );
    printf ( " \n \n \t \t \t \t \t \t Assentos Especiais \n " );
    printf ( " \t \t  \t \t \t \t A " );
      for (j = 0 ; j < 3 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "%d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Convidados do Palestrante \n " );
    printf ( " \t \t \t \t \t \t B " );
     for(j = 3 ; j < 13 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( "% d" , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Participantes \n " );
    printf ( " \t \t \t \t \t \t C " );
      for (j = 13 ; j < 23 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t D " ); 
        for (j = 23 ; j < 33 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }
    printf ( " \n " );
    printf ( " \t \t \t \t \t \t E " );
      for (j = 33 ; j < 43 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t F " );
      for (j = 43 ; j < 53 ; j ++)
    {
        if (status [j] == 0 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    // função para ver todos os ocupados
    printf ( " \n \n \n \t \t \t \t \t \t + ============================== ========================= + " );
    encontrou = 0 ;  // Bandeira para saber se existe pelo menos um assento livre
    printf ( " \n \t \t \t \t \t \t \t   *** Ocupados ***   \n " );
    printf ( " \n \t \t \t \t \t \t Assentos Especiais \n " );
    printf ( " \t \t \t \t \t \t A " );
        for (j = 0 ; j < 3 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 0 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Convidados do Palestrante \n " );
    printf ( " \t \t \t \t \t \t B " );
      for (j = 3 ; j < 13 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 0 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Participantes \n " );
    printf ( " \t \t \t \t \t \t C " );
      for (j = 13 ; j < 23 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t D " );
      for (j = 23 ; j < 33 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t E " );
      for (j = 33 ; j < 43 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t F " );
    for (j = 43 ; j < 53 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    getchar ();

}


void enviar_email ()   // erro nessa parte 
{

        int opM;
    opM = 1 ;

    while (opM != 3 )
    {
        system ( " clear " );
       printf ( " \n \n \n \n \n \n \t \t \t \t \t \t + ======================== ============================================== + " );
       printf ( " \n \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | UNIP - UNIVERSIDADE PAULISTA | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 1 - Todos os Visitantes | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 2 - Escolher Visitante | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | 3 - Retornar ao Menu Principal | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t + ====================================== ============================== + \n \n " );
       printf ( " \t \t \t \t \t \t                   Digite a opção desejada ......: " );
       scanf ( "%d " , &opM);

              switch (opM)
            {

                case  1 :
                    email_todos ();
                    break ;

                case  2 :
                    email_um ();
                    break ;

                case  3 :
                   break ;

                default:
                    printf ( " \n \t \t \t \t \t \t \t \t *** Opção Inválida! *** " );
                    getchar ();
            }
    }
}

void  email_todos ()
{

        system ( " cls " );
       printf ( " \n \n \n \n \n \n \t \t \t \t \t \t + ======================== ============================================== + " );
       printf ( " \n \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | Palestra Direito Humanos | \n " );
       printf ( " \t \t \t \t \t \t | Dr. Ramiro | \n " );
       printf ( " \t \t \t \t \t \t | Contéudo da Palestra: Direitos Humanos | \n " );
       printf ( " \t \t \t \t \t \t | Motivo: Informativo | \n " );
       printf ( " \t \t \t \t \t \t | Data: 25/12/2020 Horário: 18:30 | \n " );
       printf ( " \t \t \t \t \t \t | Local: Unip - Chácara Santo Antônio | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | Resumo | \n " );
       printf ( " \t \t \t \t \t \t | Hoje em dia as pessoas torcem o nariz para palavra | \n " );
       printf ( " \t \t \t \t \t \t | ?? Direitos Humanos ??, pois aqui no Brasil ela sempre | \n " );
       printf ( " \t \t \t \t \t \t | sempre está ligada ao crime e violência e nunca | \n " );
       printf ( " \t \t \t \t \t \t | está ao lado da vítima, mas sim daquela | \n " );
       printf ( " \t \t \t \t \t \t | causaram o Dano. Porém o que ninguém sabe que | \n " );
       printf ( " \t \t \t \t \t \t | na década de 40 em uma reunião em paris, foram | \n " );
       printf ( " \t \t  \t \t \t \t | lançados 30 artigos no rastro da segunda guerra |  \n " );
       printf ( " \t \t \t \t \t \t | Mundial, pois a falta de punição contra governos | \n " );
       printf ( " \t \t \t \t \t \t | autoritários, trabalho escravo, tortura, discriminação, | \n " );
       printf ( " \t \t \t \t \t \t | fome e pobreza violava todos os dias a vida dos seres | \n " );
       printf ( " \t \t \t \t \t \t | humanos da época. | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t + ====================================== ============================== +  \n \n " );
       getchar ();
}

void  email_um ()
{
    int as;
    printf ( " \t \t \t \t \t \t Escolha o Assento abaixo, Assim o e-mail será enviado para pessoa que está sentada no mesmo. \n " );
    encontrou = 0 ;  // Bandeira para saber se existe pelo menos um assento livre
    printf ( " \n \t \t \t \t \t \t Assentos Especiais \n " );
    printf ( " \t \t \t \t \t \t A " );
      for(j = 0 ; j < 3 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 0 ;
        }
    }

    printf ( " \n \n \n \t \t \t \t \t \t Convidados do Palestrante \n " );
    printf ( " \t \t \t \t \t \t B " );
    for (j = 3 ; j < 13 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 0 ;
        }
    }

    printf ( "  \n \n \n \t \t \t \t \t \t Participantes \n " );
    printf ( " \t \t \t \t \t \t C " );
    for (j = 13 ; j < 23 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t D " );
    for (j = 23 ; j < 33 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( "  \n" );
    printf ( " \t \t \t \t \t \t E " );
    for (j = 33 ; j < 43 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n " );
    printf ( " \t \t \t \t \t \t F " );
    for (j = 43 ; j < 53 ; j ++)
    {
        if (status [j] == 1 )
        {
            printf ( " [ % d ] " , j + 1 );
            encontrou = 1 ;
        }
    }

    printf ( " \n \t\t \t \t \t \t \t \t Necessário apenas o número do assento \n " );
    printf ( " \t \t \t \t \t \t \t \t Assento ......: " );
    scanf ( " %d " , &as);

    system ( " clear " );
    if (as> 0 && as < 54 ) {

       printf ( " \n \n \n \n " );
       printf ( " \n \n \n \n \t \t \t \t \t \t Assento: % d  \n " , as);
       printf ( " \t \t \t \t \t \t Email Enviado com Sucesso !!! \n \n " );
       printf ( " \t \t \t \t \t \t Conteúdo: \n " );
       printf ( " \t \t \t \t \t \t + ====================================== ============================== + " );
       printf ( " \n \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | Palestra Direito Humanos | \n " );
       printf ( " \t \t \t \t \t \t | Dr. Ramiro | \n " );
       printf ( " \t \t \t \t \t \t | Contéudo da Palestra: Direitos Humanos | \n " );
       printf ( " \t \t \t \t \t \t | Solicitação do Assento: % d                                | \n " , as);
       printf ( " \t \t \t \t \t \t | Motivo: Para Envio do Informativo | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | Data: 13/12/2018 Horário: 18:30 | \n " );
       printf ( " \t \t \t \t \t \t | Local: Unip - Chácara Santo Antônio | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t | Resumo | \n " );
       printf ( " \t \t \t \t \t \t | Hoje em dia as pessoas torcem o nariz para palavra | \n " );
       printf ( " \t \t \t \t \t \t | ?? Direitos Humanos ??, pois aqui no Brasil ela sempre | \n " );
       printf ( " \t \t \t \t \t \t | sempre está ligada ao crime e violência e nunca | \n " );
       printf ( " \t \t \t \t \t \t | está ao lado da vítima, mas sim daquela | \n " );
       printf ( " \t \t \t \t \t \t | causaram o Dano. Porém o que ninguém sabe que | \n " );
       printf ( " \t \t \t \t \t \t | na década de 40 em uma reunião em paris, foram | \n " );
       printf ( " \t \t \t \t \t \t | lançados 30 artigos no rastro da segunda guerra | \n " );
       printf ( " \t \t \t \t \t \t | Mundial, pois a falta de punição contra governos | \n " );
       printf ( " \t \t \t \t \t \t | autoritários, trabalho escravo, tortura, discriminação, | \n " );
       printf ( " \t \t \t \t \t \t | fome e pobreza violava todos os dias a vida dos seres | \n " );
       printf ( " \t  \t \t \t \t \t | humanos da época. | \n " );
       printf ( " \t \t \t \t \t \t | | \n " );
       printf ( " \t \t \t \t \t \t + ====================================== ============================== + \n \n " );

       getchar ();

    }
    else {
       printf ( " \t \t \t \t \t \t Assento Inválido \n " );
       getchar ();
    }
       getchar ();

}

void  realizar_sorteio ()
{
    srand (time(0)); // escolhe sequencia de numeros aleatorios
    int valores [] = { 1 , 2 , 3 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 34 , 35 , 36 , 37 ,38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , 48 , 49 , 50 , 51 , 52 , 53 };
    int n = sizeof valores / sizeof * valores;
    n =rand()%53;
    printf ( " \t \t \t \t \t \t \t \t + ================================== == + \n " );
    printf ( " \t \t \t \t \t \t \t \t PARABÉNS !!!! \n " );
    printf ( " \t \t \t \t \t \t \t \t *** Assento: % d *** \n " , valores [ rand ()%n]);
    printf ( " \t  \t \t \t \t \t \t \t Você foi Sorteado !!!!! " );
    getchar ();



}

 

 

fazendo.h
 

// fazendo.h
int        valida_senha(const char*,const char*);
// fim

 

fazendo.c

Spoiler


#include <stdio.h>
#include <string.h>

char    _login(const char* usuario, const char* senha)
{
    return 1; // ok
};


int         valida_senha(const char* login, const char* senha)
{
    int t = 0;
    printf("valida_senha(): login '%s' senha '%s'\n",
        login, senha);
    if ( t == 0 ) return 1;

    int verifica_senha = 0 ;
    int verifica_user = 0 ;
    int i, u;
    char c;
    char l;
    u = 0 ;
    i = 0 ;
    while ((c = getchar ()) != 13 )
    {
       //senha [i] = c;
       //login [u] = l;
       u ++;
       i ++;
       printf ( " * " );
    }

    //login [u] =  0  ;
    //senha [i] =  0 ;
    i = 0 ;
    u = 0 ;
    l = strcmp (login, " adm " );
    c = strcmp (senha, " 1 " );

    if (c == 1 && l == 1 ) // Senha e usuario Inválida
    {
        printf ( " \n \n \t \t \t \t \t *** Senha ou Usúario inválido! Tente novamente *** \n \n " );
        t = t + 1 ;
        getchar ();
    }
    else // Senha e Usuario Correta
    {
        verifica_user = 1 ;
        verifica_senha = 1 ;
    }
    if (t == 3 )
    {
      // sistema ("cls");
      printf ( " \n \n \t \t \t \t \t *** Acesso Negado! *** \n \n " );
      getchar (); 
    }
} 	// Fim da Função Valida Senha e Usuario

 

 

Espero que tenha entedido a diferença. É importante. Acho que não deve seguir sem entender isso.

 

 

 

@Murilo Murilo não entendi o que quis dizer no post #11. Veja o exemplo que te mostrei e tente implementar em seu código. E entender o que expliquei. 
 

Esse é o modo usado em geral para escrever esse tipo de coisa. Esteja certo de ter entendido a diferença. É grande.

  • Curtir 2
Link para o comentário
Compartilhar em outros sites

Crie uma conta ou entre para comentar

Você precisa ser um usuário para fazer um comentário

Criar uma conta

Crie uma nova conta em nossa comunidade. É fácil!

Crie uma nova conta

Entrar

Já tem uma conta? Faça o login.

Entrar agora

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!