#include <stdio.h>
#include <string.h>
#include <stdbool.h>
struct Fam {
char me[20];
char mom[20];
char dad[20];
};
bool isSiblings(struct Fam fam1, struct Fam fam2) {
if (strcmp(fam1.mom, fam2.mom) == 0)
return true;
else
return false;
}
// Pass a pointer to `family` to modify the original struct in `main`
void getNames(struct Fam *family) {
// Get my name
printf("Enter your name: \n");
fgets(family->me, sizeof(family->me), stdin);
family->me[strcspn(family->me, "\n")] = '\0';
// Get mom's name
printf("Enter your mom's name: \n");
fgets(family->mom, sizeof(family->mom), stdin);
family->mom[strcspn(family->mom, "\n")] = '\0';
// Get dad's name
printf("Enter your dad's name: \n");
fgets(family->dad, sizeof(family->dad), stdin);
family->dad[strcspn(family->dad, "\n")] = '\0';
}
int main() {
struct Fam family1;
// Pass the address of `family1` to `getNames`
getNames(&family1);
printf("Your name: %s, Mom: %s, Dad: %s\n", family1.me, family1.mom, family1.dad);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: