i am a beginner in C programming, and while making a program i wondered if there can be a universal input function input();
be made, such that the variable name given in braces be asked for input like this:
input(a);
result:
enter value of a: 10
now (after the input) if i write like this in any program like:
#include<stdio.h>
main()
{
int a;
float b;
char c;
input (a);
printf("value of a = %d\n",a); // 1
input(b);
input(c);
printf("value of b = %f\n",b); // 2
printf("c = %c\n",c); // 3
}
then output should be like this:
output:
enter value of a: 10
***value of a = 10***
enter value of b: 10.0
enter value of c: D
***value of b = 10.000000***
***c = D***
i.e the function parameter should take values acording to the type of variable concerned(like char,float,int etc) like if a
were char then value entered in a
would be saved accordingly.
i thought to implement it using structures but i am not able to think, how to link the actual parameter passsed in input();
with the struct members
update: i have written the lines 1,2,and 3(in comments: the printf()
functions) just to show that the values of a,b, and c are aptly/rightfully stored in their corresponding types