0

Please help me to understand why it is so no output

void fun() { } int main(void) { fun(10, "GfG", "GQ"); return 0; }

13th Dec 2022, 4:36 AM
Abhishek
Abhishek - avatar
9 Answers
+ 4
Abhishek I just checked on Geeksforgeek there is also no output because there is no print function But if you run this program in C++ you may get error.
13th Dec 2022, 6:47 AM
A͢J
A͢J - avatar
+ 3
Abhishek I'm very new to c and just went thru the course recently, probably too quickly, so there may better answers. You seem to have many missing parts in your code, for example no print statements (printf, fputs). And with my limited knowledge (I'm better with c++) I think you have to pass the arguements to the void function. Here's an example below. But, to be polite, I think you really need to review and finish the Introduction to C course if you want to better understand how to get output and use functions. Keep working! https://code.sololearn.com/cUNAs5OGg6Lr/?ref=app
13th Dec 2022, 5:54 AM
Scott D
Scott D - avatar
+ 1
Abhishek That may be. But judging from what you posted, there are missing parts to the code. void fun() {} creates a function. But there is nothing in the function or in int main that I see that would create output. The probability is that the function was created above int main and you are missing code from below int main that is the rest of the void function. Geeksforgeeks is a good site. Either what you posted is only part of the code or is part of a lesson. But what you posted will not produce an output as it stands, not to the best of my knowledge. If I'm incorrect I'm sure someone will point that out.
13th Dec 2022, 6:21 AM
Scott D
Scott D - avatar
+ 1
Abhishek I would like to help. But if you are a beginner you need to follow the whole course Introduction to C before you are able to understand. Picking things from other sites and trying to understand them won't help you learn. First you must understand some things. Do you know what a char is? A char array[]. An integer (int)? A static int vs an int? The difference between a void function and int main? I cannot write out an entire course in the discuss forum. If you have specific questions about a code I or others can answer questions but you need to do the work in the course to learn. Your profile shows you only at the beginning of the C course. The code you posted concerns strings and functions which are at the end of the course. You need to be patient until you get thru it, I think you're trying to jump ahead a little too quickly.
13th Dec 2022, 6:41 AM
Scott D
Scott D - avatar
0
Bro I just read from geeks for geeks
13th Dec 2022, 6:11 AM
Abhishek
Abhishek - avatar
0
#include <stdio.h> int main() {     static int i = 5;     if (--i){         printf("%d ", i);         main(10);     } }
13th Dec 2022, 6:24 AM
Abhishek
Abhishek - avatar
0
#include <stdio.h> int main() {     static int i = 5;     if (--i){         printf("%d ", i);         main(10);     } }
13th Dec 2022, 6:29 AM
Abhishek
Abhishek - avatar
0
Help me in this code also I want to understand the logic and when we pass any value to main the prog.still works
13th Dec 2022, 6:29 AM
Abhishek
Abhishek - avatar
0
Ok sir thank u
13th Dec 2022, 6:55 AM
Abhishek
Abhishek - avatar