+ 4
Convert code to C language
#include<stdio.h> struct Course { int user; int video; int level; void ShowInfo() { printf("Number of users:"); printf("user\n"); printf( "Number of video:"); printf("video\n"); printf("Numbre of course:"); printf("Numbre\n"); } }; int main() { Course py; py.user= 3192; py.video = 15; py.level =3; py.ShowInfo(); return 0; One can change this code to C language,,, I do not know what my problems are 🥺🙏
6 Answers
+ 4
#include<stdio.h>
typedef struct Course {
int user;
int video;
int level;
} Course;
void ShowInfo(Course c) {
printf("Number of users:");
printf("%d\n", c.user);
printf( "Number of video:");
printf("%d\n", c.video);
printf("Numbre of course:");
printf("%d\n", c.level);
}
int main() {
Course py;
py.user= 3192;
py.video = 15;
py.level =3;
ShowInfo(py);
return 0;
}
+ 3
C structs are plain data carrier, I think you can turn that ShowInfo() into a regular function, allow it to accept a parameter of struct `Course` type, which will be used as source of data to print.
+ 2
So how do I change the code?
+ 2
Tnxxxx🙏🙏
+ 1
In C a struct can't have functions in it
0
He would be welcome xxx