Struct - Repair Code

PHOTO EMBED

Mon Jun 10 2024 12:26:16 GMT+0000 (Coordinated Universal Time)

Saved by @meanaspotato #c #struct

#include <stdio.h>
#include <string.h>

struct Student
{
    char name [50]; //declare as character array with space for 50 characters
    float lecture_attendance;
    float lab_attendance;
};

int main(void)
{
    struct Student student;
    
    sprintf(student.name,"Jane Doe"); //use sprintf to format and store the string into the name array of the student structure.
    student.lecture_attendance = 0.33f;
    student.lab_attendance = 1.00f;
    printf("Successful!!!");
    return 0;
}
content_copyCOPY

original: #include <stdio.h> #include <string.h> struct Student { char name; float lecture_attendance; float lab_attendance; }; int main(void) { struct Student student; student.name = "Jane Doe"; student.lecture_attendance = 0.33f; student.lab_attendance = 1.00f; printf("Successful!!!"); return 0; } Requirements Given Source Code: The original code is given below. Compiler Warnings and Errors: The compiler generates warnings treated as errors, halting compilation. Warning about padding added after the name member. Warning about data type mismatch for the name member. Describe the Fixes: In your comments, describe what was wrong with the source code and explain how you fixed each issue.