Question about printf...

O

Olaf \El Blanco\

For example...

typedef struct {
int valid;
char name[MAX_NAME];
char lastname[MAX_LASTNAME];
int age;
float note;
char DNI[MAX_DNI];
} TPupil;

TPupil *Ram;

printf ("%10s, %10s %16d %15.2f %15s\n", *Ram->lastname, *Ram->name,
Ram->age, Ram->note, *Ram->DNI);

Why "Ram->age" and "Ram->note" don't need the '*' ?

And, How can I make each follow lines shorter?

(*(Ram + cant - 1)).valid = temp.valid;
(*(Ram + cant - 1)).age = temp.age;
(*(Ram + cant - 1)).note = temp.note;
strcpy( (*(Ram + cant - 1)).DNI, temp.DNI);
strcpy( (*(Ram + cant - 1)).name, temp.name);
strcpy( (*(Ram + cant - 1)).lastname, temp.lastname);
 
I

Ian Collins

Olaf said:
For example...

typedef struct {
int valid;
char name[MAX_NAME];
char lastname[MAX_LASTNAME];
int age;
float note;
char DNI[MAX_DNI];
} TPupil;

TPupil *Ram;

printf ("%10s, %10s %16d %15.2f %15s\n", *Ram->lastname, *Ram->name,
Ram->age, Ram->note, *Ram->DNI);

Why "Ram->age" and "Ram->note" don't need the '*' ?
None of them do.

*Ram->lastname is the first character in Ram->lastname, that is
Ram->lastname[0].
And, How can I make each follow lines shorter?
use a temporary,

TPupil* tmp = Ram+(cant - 1);

tmp->valid = temp.valid;

and so on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,183
Messages
2,570,965
Members
47,511
Latest member
svareza

Latest Threads

Top