-7

I'm currently trying to write a program in C with the following structure:

int alpha()
{
    blablabla...  //returns 0,1,2,3,4 or 5 depending on input
}

int beta()
{
    blablabla...  //needs to return the value that alpha returns
}

How - if possible - can I get beta to return the return value of alpha?

I realise this is a dumb structure but unfortunately it is necessary in order to work with a header file.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
confus
  • 3

3 Answers3

4
int beta()
{
    return alfa();
}

:)

stryku
  • 722
  • 5
  • 12
2

You can get the input for example with scanf("%d", &value); you may then want to check if valid input was entered, and then return the value in that case, you could designate an invalid value to indicate that the function didn't recieve valid input

int alpha()
{
    int value;
    /* get value from input */
    return value;
}

and as stryku already answered

int beta()
{
    return alpha();
}
Iharob Al Asimi
  • 52,653
  • 6
  • 59
  • 97
1

you can call alpha from inside beta, so you can get use of alpha's return value

mrbioeng
  • 19
  • 4