Здравствуйте, я пытаюсь вернуть struct из функции, но не могу найти способ сделать это без объявления struct как глобальной. Как это можно сделать? Вот код (ЭТО РАБОТАЕТ КАК ЕСТЬ)
...
void log_in();
struct node
{
char name_log[20];
int passlog;
int user_point;
}tmp;
int main()
{
...
else if(sel=='2')
{
log_in();
if (tmp.passlog==TRUE)
logged_in(tmp.name_log,tmp.user_point); //and here i want to use the retun values
}
void log_in()
{
... //make the changes in the struct
}
...
То, чего я хочу добиться, это разместить объявление узла struct внутри main, но, к сожалению, это не работает. Вот что я пытаюсь сделать: (ЭТО НЕ РАБОТАЕТ)
...
struct node log_in();
int main() {
...
else if(sel=='2') {
struct node //here is where i want to declare
{
char name_log[20];
int passlog;
int user_point;
}tmp;
log_in();
if (tmp.passlog==TRUE)
logged_in(tmp.name_log,tmp.user_point); //and here i want to use the retun values
}
struct node log_in()
{
...
return tmp;
}
...