assignment(1)_Advanced_c_
assignment(1)_Advanced_c_
Call by Reference
Data Structure:
struct Customer {
int customerID;
char name[50];
char address[100];
char phone[20];
char email[50];
char paymentInfo[100];
};
8- Create a C functions to Add new record and view payment using
the output of the following figures
9- Identify the functions that are used to dynamically allocate memory
location during runtime and the function of the following string
functions
- strcpy
- strcmp
- strlwr
- strlen
Dynamic memory allocation in C:
1: The malloc() function allocates single block of requested memory.
• memory allocation
• It doesn't initialize memory at execution time,so it has
garbage value initially.
• It returns NULL if memory is not sufficient.
The syntax of malloc() function is
ptr=(cast-type*)malloc(byte-size)
__________________________
2: calloc() function is used to dynamically allocate multiple blocks of
memory.
• calloc() needs two arguments instead of just one
void *calloc(size_t n, size_t size)
first argument is the number of blocks
second argument is the size of each block
• Memory allocated to calloc is initialized to zero but malloc
is initialized with some garbage value
______________________________
10- Write the full C program to implement the university staff billing
system.