C programming
Consider the following struct definition:
struct player {
char letter;
int age;
}
typedef struct player player_t;
Write a program to do the following:
#include<stdio.h>
#include<stdlib.h>
struct player {
char letter;
int age;
};
typedef struct player player_t;
void fun(player_t *p)
{
p->age = p->age+1;//incrementing age by1
}
int main()
{
player_t *p;//declaring pointer
p = (player_t *)malloc(sizeof(player_t));//allocating memory
//initializing
p->letter='M';
p->age=23;
//printing
printf("%c %d\n",p->letter,p->age);
//passing to function
fun(p);
//printing
printf("%c %d\n",p->letter,p->age);
//freeing memory
free(p);
return 0;
}
output:
M 23
M 24
Process exited normally.
Press any key to continue . . .
//PLS give a thumbs up if you find this helpful, it helps me alot,
thanks.
//if you have any doubts, ask me in the comments
C programming Consider the following struct definition: struct player { char letter; int age;...