Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help!!! 1. Write a C program that creates a structure named student with

ID: 3832178 • Letter: P

Question

Please help!!!

1. Write a C program that creates a structure named student with three members (name, last name and id).
Enter 2 student's information and save it in a txt file.

2. Write a C program that creates a union named "users" with two members (last name and email).
Enter 3 users's information, print it (make sure you print the correct values) and save the correct values in a txt file.

3. What is wrong or missing in this code to avoid errors or warnings?

#include<stdio.h>
#include<conio.h>
void main() {
    union details {
      struct student st;
   };
   union details set;
    printf("Enter details:");
    printf(" Enter FIrst name : ");
   scanf("%s", set.st.first_name);
   printf(" Enter id : ");
   scanf("%d", &set.st.id);

   printf(" First name : %s", set.st.first_name);
   printf(" Id : %d", set.st.id);
   getch();
   }

4. What is wrong or missing in this code to avoid errors or warnings?

#include <stdio.h>
int main() {
   char buff[255];

   fp = fopen("C:\temp\test1.txt", "r");
   fscanf(fp, "%s", buff);
   printf("1 : %s ", buff );

   fgets(buff, 255, (FILE*)    );
   printf("2: %s ", buff );


   return 0;

}

5. Write a program to insert the binary sequence [1 0 0 0 1 0 1 1] in a register named "my_register" using bit fields."

Comments

Explanation / Answer

#include<stdio.h>
#include<conio.h>
void main() {
    union details {
      struct student st;
   };
   union details set;
    printf("Enter details:");
    printf(" Enter FIrst name : ");
   scanf("%s", set.st.first_name);
   printf(" Enter id : ");
   scanf("%d", &set.st.id);

   printf(" First name : %s", set.st.first_name);
   printf(" Id : %d", set.st.id);
   getch();
   }

#include <stdio.h>
int main() {
   char buff[255];

   fp = fopen("C:\temp\test1.txt", "r");
   fscanf(fp, "%s", buff);
   printf("1 : %s ", buff );

   fgets(buff, 255, (FILE*)    );
   printf("2: %s ", buff );


   return 0;

}