First of all you might wonder why I don't just use 1 function: The reasoning behind this is that I need this for a bigger project and want to keep the functions as separated as possible. I also don't want to use any global variables. This is the code I used to test this:
#include <stdio.h>
int Variables (int a, int b, int c) /* Example of a function wich stores
variables with user input */
{
printf("input variables");
scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
printf("%d:%d:%d\n", a, b, c);
return a, b, c;
}
int main (void)
{
int a, b, c;
/* I want to use the variables with userinput from the Variables function */
printf ("\n%d:%d:%d\n", Variables(a, b, c));
return 0;
}
Unfortunately the output always returns only 1 of the inputs I stored in the variables from function Variables () and then 2 completely unrelated random numbers. I wonder how this could be fixed. Also bear with me on this I am pretty new to programming and c so I might have overlooked something. Thanks in advance for answers!
Edit: Apparently I got a lot of things wrong. Thanks for all the helpful answers! I guess the correct question to ask would have been "How to return more than 1 value from a function". Sorry for this unintended duplicate question. Maybe this question still helps people who ran into the same misconception (thinking that you can return more than 1 value from a function and thus searching for the wrong question on the internet).