Can we reassign the variable values in main() function by using the user defined function (return type || void )? In C | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can we reassign the variable values in main() function by using the user defined function (return type || void )? In C

Without using pointers and global variable...

17th Oct 2020, 6:47 AM
Yogeshwaran P
Yogeshwaran P - avatar
8 Answers
+ 2
Didn't get the "reassign the values in main()" here, did you mean change local variables in main() function?
17th Oct 2020, 6:50 AM
Ipang
+ 2
Yes Ipang, how to change local variable in main () function using user defined function...
17th Oct 2020, 7:29 AM
Yogeshwaran P
Yogeshwaran P - avatar
+ 2
It means pointer useful for void function to reassign the local variables? Am I right codemonkey ?
17th Oct 2020, 7:44 AM
Yogeshwaran P
Yogeshwaran P - avatar
+ 2
Thank you so much codemonkey ๐Ÿ™Œ
17th Oct 2020, 7:59 AM
Yogeshwaran P
Yogeshwaran P - avatar
+ 2
I wrote this simple program for you to show that it is possible to change variables in main() from a void function without passing pointers or global variables. Please, never do this!!! https://code.sololearn.com/c7vF6GzfXama/?ref=app
17th Oct 2020, 11:54 AM
Brian
Brian - avatar
+ 1
codemonkey, I found that your code reassign the local variable using user defined function[return type].... Then what is the use of pointer function....? To reassign the local variables in main() function..... is pointer function used for void return type function to reassign the local variable? am I right ?
17th Oct 2020, 7:33 AM
Yogeshwaran P
Yogeshwaran P - avatar
+ 1
Thank you everyone for solving my queries๐Ÿ˜Š๐Ÿ™
17th Oct 2020, 10:46 AM
Yogeshwaran P
Yogeshwaran P - avatar
+ 1
Martin Taylor why we are using void inside the main function? i.e int main(void);๐Ÿ˜… What is the use of it...
17th Oct 2020, 1:28 PM
Yogeshwaran P
Yogeshwaran P - avatar