Can someone help me with this program on Ansi C, CRUD program?

Asked

Viewed 146 times

1

I tried to erase half of the code and leave it only with the first block, but keeps giving error in the operators and in each scanf that I give, being that I need to find a way to assign the values that I take scanfs and play within the proper variables. Can someone please help me?

#include <stdio.h>
#include <stdlib.h>
char _nome[20];
int _idade[9];
int _cpf[11];
main()
         {
            const int dez = 10;
            printf("O CRUD - cadastre o usuário, com nome, idade, cpf\n Nome: ");
                scanf("%s" &_nome);
            prinf("Idade: \n");
                scanf("%d" &_idade)
            printf("CPF(digite sem os pontos e sem traços): \n");
                scanf("%d" &_cpf);
            printf("usuário cadastrado com sucesso! \n Deseja alterar os dados de algum usuario? \n s ou n");
            scanf("s || n");
            if (scanf "s" == 1);
            else
            system("pause");
            printf("Qual dos dados do usuário você deseja alterar? \n Nome = 1 \n Idade = 2 \n CPF = 3 \n");
                if (scanf == 1);
                    function _Leitura(get_pointer_safety);
                    if (scanf == 2);
                        function _Alterar(get_pointer_safety);
                        if (scanf == 3);
                        function _Excluir();
                        else
                        system("pause")
                    else
                    system("pause");
                else
                system("pause");

         }
         function _Leitura(get_pointer_safety)
         {
            if return _nome = 1;
            getchar();
            putchar() &char = &putchar(&_nome);
            else
            system("pause");
         }
         function _Alterar()
         {
            printf("alterando dados do usuário... \n Nome: ");
            getchar();
            putchar(_Usuario());
            printf("Idade: \n");
                scanf("%d");
            printf("CPF: \n");
                scanf("%d");
            printf("Mais alguma coisa? \n s ou n");
                scanf("%s")
            if scanf("%s") == "s"
            return _a
            else
            system("pause");
         }
         function _Excluir()
         {

         }
  • There is a lot wrong there Ramon. The Sintaxis in the structures if it is wrong and the scanf should be used as function not as object.

  • one of the reasons I turn here, is precisely the various flaws that are giving to this, but like, me and a friend of mine are digging here in the code for a long time this morning, and we can’t get much success no, why although I declare before the main block the read, change and delete functions, is giving error in the scanfs, all right, I just really wanted a way to assign the values I took of each function scanf declared and put in the proper variables, already tried the getchar and putchar in each printf but still yes, it did not work very well... =/

  • Guy here ran a lot of bugs. But I didn’t finish the program.

  • Bro, don’t need to finish the program, in case, it would help a lot if you send the Pastebin than you managed to solve, then I take a look at what was set up and study a little deeper and it works out too

  • test that code there. Accept the answer and vote so I can earn some points.

1 answer

1

Try making the following modifications:

#include <stdio.h>
#include <stdlib.h>
char _nome[20];
//int _idade[9];
int _idade;
char _cpf[11];
const int dez = 10;
int _Leitura(void);
int _Alterar(void);

void main(){

    int opt = 0;
    char continuar = 'n';
    //const int dez = 10;

    printf("%s", "O CRUD - cadastre o usuário, com nome, idade, cpf\n Nome: ");
    scanf("%s", &_nome);
    printf("Idade: \n");
    scanf("%d", &_idade);
    printf("CPF(digite sem os pontos e sem traços): \n");
    scanf("%s", _cpf);
    printf("usuário cadastrado com sucesso! \n Deseja alterar os dados de algum usuario? \n s ou n");
    scanf("%s", &continuar);

    if (continuar == 's'); //            if (scanf "s" == 1);
        else
        system("pause");

    printf("Qual dos dados do usuário você deseja alterar? \n Nome = 1 \n Idade = 2 \n CPF = 3 \n");
    scanf("%d", &opt);

    if (opt == 1)
        _Leitura();
    if (opt == 2)
        _Alterar();
    if (opt == 3)
        1;
        //_Excluir();
    else
        system("pause");
              /*  else
                    system("pause");
                else
                system("pause");*/

}

int _Leitura(void){

    if (_nome == '1')
        getchar();
//            putchar() &char = &putchar(&_nome);
    else
        system("pause");
}

int _Alterar(void){

    char continua;
    int _a = 1;
    printf("alterando dados do usuário... \n Nome: ");
//            getchar();
            //putchar(_Usuario());
    scanf("%s", &_nome);
    printf("Idade: \n");
    scanf("%d", &_idade);
    printf("CPF: \n");
    scanf("%d", &_cpf);
    printf("Mais alguma coisa? \n s ou n");
    scanf("%s", &continua);
    if (continua == 's')
        return _a;
    else
        system("pause");
}

/*         function _Excluir()
         {

         }*/

This example already compiles, so it will help you understand syntax and allow you to debug while running

  • Dude vlw bro, and even if I don’t compile here (my release of Ubuntu sucks) it already helps in my thing, vlw bro really serious

  • tbm have Ubuntu. Know how to compile neh? >>>gcc filename. c -the filename and then . /filename

  • yeah, I’m trying here

  • Dude, whirled here, thanks bro, helped a lot here, I’ll see here about the opt function that you put some opt within the IF parameters, I still don’t know much about, but I’ll take a look further sinking here, ta rotating here, valeu mano

  • You’re welcome, Ramon boy. This opt is not a function is a variable where you save the option typed by the user, it is only to save 1, 2 or 3 and then compare in if.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.