Exforsys
+ Reply to Thread
Results 1 to 3 of 3

Confused With Error

This is a discussion on Confused With Error within the C and C++ forums, part of the Programming Talk category; My C program is as below: main() { x() { t() { printf("Hello"); } printf("Welcome"); } printf("Bye"); } When I ...

  1. #1
    Ralph is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    114

    Exclamation Confused With Error

    My C program is as below:
    main()
    {
    x()
    {
    t()
    {
    printf("Hello");
    }
    printf("Welcome");
    }
    printf("Bye");
    }

    When I compiled my program I got error instead of the output getting printed as Hello Welcome Bye. Why is it so? Kindly explain me on this.


  2. #2
    Adrian is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    124
    You would have got the error as Statement missing ; in function main. Am I right? So you would be thinking whether you have missed any ;. But the error message does not indicate that. It denotes that one must not define another function within the body of another function. In your program you have defined function x() and t() inside main() which gives you error. Define that outside the function main and call the function inside main() your problem would be resolved.


  3. #3
    Adrian is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    124
    You would have got the error as Statement missing ; in function main. Am I right? So you would be thinking whether you have missed any ;. But the error message does not indicate that. It denotes that one must not define another function within the body of another function. In your program you have defined function x() and t() inside main() which gives you error. Define that outside the function main and call the function inside main() your problem would be resolved.


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...