Hi All,
Im very beginner at C but my teacher gave me an excercise and I can not do it. The task is to create a struct called "team". This struct contains a char: "char c", and an int: "int length" and a char array: "nam[10]. I have to write a function named "newteam". The input of the function is string:actually the name of the team.
What this function should do is get the input string, and store it in the "length" and drop the first character of the string into the "char c".
I have this code so far:
How should I print out the values?Code:#include <stdio.h> #include <stdlib.h> typedef struct team_struct *Teams; typedef struct team_struct{ char f; char nam[10]; int length; }; Teams newteam(char *nam){ Teams s = malloc(sizeof(Teams)); s->length = strlen(nam); }; int main() { newteam("SomeName"); printf("%d",team_struct.length); }
Thanks for your help!