Exforsys

Online Training

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&...


Go Back   Exforsys > Programming Talk > C and C++

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-29-2007, 11:34 AM
Senior Member
 
Join Date: Apr 2006
Posts: 139
Ralph is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-02-2007, 02:12 AM
Senior Member
 
Join Date: Apr 2006
Posts: 141
Adrian is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-02-2007, 02:12 AM
Senior Member
 
Join Date: Apr 2006
Posts: 141
Adrian is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
web.config gives error if i store string that contin "&" character in appSettings mahehs_k_anjani Microsoft .NET 2 09-06-2006 06:21 AM
Comp.Sys.Acorn.FAQ part 2 of 4 Paul Vigay Tech FAQ 0 05-31-2004 09:00 PM
Apple II Csa2 FAQs: Error List, Part 8/25 rubywand@swbell.net Tech FAQ 0 05-04-2004 10:01 AM
Comp.Sys.Acorn.FAQ part 2 of 4 Paul Vigay Tech FAQ 0 04-30-2004 09:00 PM
Kerberos FAQ, v2.0 (last modified 8/18/2000) Ken Hornstein Tech FAQ 0 04-17-2004 08:28 AM


All times are GMT -4. The time now is 12:18 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.