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

I need clearification on what a structure is in C, my confusion comes from the i

ID: 3879018 • Letter: I

Question

I need clearification on what a structure is in C, my confusion comes from the instructions I was given as a "modular approach to writting C code" :

----------------------------------------------------------------------------------------------

From these instructions it seems I am supposed to make a file for every function with the (name of function).c incuding my.h in these function files, as for this my.h it says I need structures, but no variables. I thought pointers were structures declared by varibales such as in my case, "int *pointerNUM", I need this to be used in most my functions, So my question is how can you have structures, but no variables when u making your pointers named something?

Explanation / Answer

Hey there,
C Structure is a collection of different data types which are grouped together and each element in a C structure is called member.

We use struct keyword to define structure in c.
for example:-

struct person{
//declare structure member

int age;
int mobile;
char name[20];
};

Structure definition always ends with semicolon.

as per your understanding structures are pointers. you can assume structure as an user defined data type and have pointers to it. For example we can have pointers to above defined structure in different functions. such as:-

void main(){

person *you;
}

Now coming to your question, you are asked to have structures in my.h file. you dont need to declare variables in my.h file. So your my.h file goes like this.

in my.h

#include<stdio.h>
#include<anyother.h>

int f1(int a, int b);/* declare any function prototype of your need/*

//structures

struct st1{
//declare members that you need
};

struct st3{
//declare members that you need
};

//variables
// you are asked not to have any variables.


i hope i have clarified your doubt.please upvote and comment if you need more clarification.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote