I'm working on a project in C. I need to print four variables in the same line: 3 of them are integers and 1 is an array that stores a string. The problem that I'm having is when I try to print all in the same line. After I print the array it jumps lines. I don't want it to jump lines because I need all of the variables on the same line.
This is the start that I made:
#define MAX 100
struct cadastro
{
int id;
char nome[MAX];
int datanascimento;
int cpf;
};
This is how I'm trying to print it:
printf("ID: %i Nome: %s Data de nascimento: %i CPF: %i", cdto[c].id, cdto[c].nome, cdto[c].datanascimento, cdto[c].cpf);
This is what I receive as feedback from printing:
ID: 0 Nome: Nilton
Data de nascimento: 2 CPF: 2
I'm using fgets()
to get the name typed.