hello. I am studying C from "C programming-A modern approach" by 'KN King'. I am stuck at structures topic while he tells about a function, using which we can pass & assign the elements of structure. I am not able to complete it.
Code:
#include<stdio.h>
#include<string.h>
struct part_build (int num,char *name, int on_hand)
{
struct part p;
p.number=num;
strcpy(p.name,name);
p.on_hand=on_hand;
return p;
}
int main(void)
{
struct part part1; //IT WASN'T THERE IN BOOK, BUT WRITING IT HERE AVOIDS AN ERROR
part1=part_build(1,"tyre",22);
}
I am new to structures and it is spinning me since yesterday... Thanks...