-1
main()
{
           int a;
           a=message();
}
message()
{
          printf("\n C language");
}

//what is the output and what return will return to a";

Edited by __avd: Added [code] tags. Encase your code in: [code] tags.

Votes + Comments
Major fail, rezzing a 2.5 year dead thread with an irrelevant post that has no [code] tags and won't even work.
4
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by Ancient Dragon
1

start quote:

main()
{
           int a;
           a=message();
}
message()
{
          printf("\n C language");
}

what is the output and what return will return to a;

Since this is the C++ forum there would be no output from that since C++ does not support implicit types on functions or calling functions without a prototype so the code will not compile.

Assuming that you meant to compile it as C and that you are willing to ignore the warnings produced rather than fix them then the output of the code is either undefined behaviour or extremely platform defined.

Edited by mike_2000_17: Fixed formatting

Votes + Comments
Another 3 year resurrection...
1

Why not compile and run it to see the output yourself? Why not also modify the code to output the value of the variable "a" to see what is returned by the message() function, or debug to see what is there during runtime?

If you can't figure it out in your head, your best bet is to put it into practice and see what happens, i.e. run it.

0

Hint: The return value to a is undefined because the function doesn't explicitly return a value. Also, most modern compilers will produce errors on that code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.