#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Person {//can be written in header file
char name[50];
int no;
};
void print(struct Person person) {//can be written in header file
printf("%s\n", person.name);
printf("%d\n", person.no);
}
int main() {
struct Person p1;
// Initialize p1 with the data directly
strncpy(p1.name, "Adarsh", sizeof(p1.name) - 1);
p1.name[sizeof(p1.name) - 1] = '\0'; // Ensure null termination
p1.no = 1;
print(p1);
// Clear sensitive data
memset(p1.name, 0, sizeof(p1.name));
p1.no = 0;
// Reuse the struct for a new person
strncpy(p1.name, "Adithya", sizeof(p1.name) - 1);
p1.name[sizeof(p1.name) - 1] = '\0'; // Ensure null termination
p1.no = 2;
print(p1);
// Clear sensitive data
memset(p1.name, 0, sizeof(p1.name));
p1.no = 0;
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: