0
I want to receive the input of a user and at the end I run the program I want to show them, but I think the variable address is not like that, because the program jumps from name to age directly, and first I should let the address and does not leave, what I want is to create a program in C in order to save the contacts of users the code is this:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char** argv) {
char nome[50], morada[100];
int idade;
int montdep;
long int numconta;
printf("Introduza o seu nome:\n");
scanf("%[^\n]s",nome);
fflush(stdin);
printf("Introduza a sua morada:\n");
scanf("%[^\n]s",morada);
fflush(stdin);
printf("Introduza a sua idade:\n");
scanf("%d",&idade);
if(idade<=-1)
{
printf("Não se aceita valores negativos\nReinicie programa");
}
else
{
printf("Introduza o valor a depositar:\n");
scanf("%d",&montdep);
printf("Introduza o numero de conta :\n");
scanf("%ld",&numconta);
printf("%s com morada%s de %d anos, depositou %d€ na conta %ld",nome,morada,idade,montdep,numconta);
}
}
the result is this:
Introduza o seu nome:
luis esquinas
Introduza a sua morada:
Introduza a sua idade:
25
as you can see he won’t let me enter the address and that’s where I made the mistake.
Thanks, thanks, it worked for what you wanted
– Sergio Nunes
Of nothing, any doubt just talk =).
– Matheus Martins
how can I send data to a txt file to a specific directory on the pc?
– Sergio Nunes