943,626 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1529
  • C RSS
You are currently viewing page 1 of this multi-page discussion thread
May 27th, 2009
0

clrscr is usually given after declaration of variables. why ?

Expand Post »
clrscr() is usually given after the declaration of all variables. If it is given before the declaration(of variables), the compiler points out an error. Why is this due to ? Will there be any problem in allocating the required amount of memory if at all clrscr() is given before the declaration?

Kindly reply to this question !!

Thanks !!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rocky2008 is offline Offline
9 posts
since Jun 2008
May 27th, 2009
0

Re: clrscr is usually given after declaration of variables. why ?

Read "C Program Structure" section from your text book. I am sure, you will get the answer.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
May 27th, 2009
0

Re: clrscr is usually given after declaration of variables. why ?

you can't put executable statements before variable declarations in C language.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
May 27th, 2009
0

Re: clrscr is usually given after declaration of variables. why ?

i couldn't find the answer. can u please help me if you know the answer.
Click to Expand / Collapse  Quote originally posted by adatapost ...
Read "C Program Structure" section from your text book. I am sure, you will get the answer.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rocky2008 is offline Offline
9 posts
since Jun 2008
May 27th, 2009
0

Re: clrscr is usually given after declaration of variables. why ?

thanks for your response. but can u please tell me why executable statements cant be given before variable declaration ?
you can't put executable statements before variable declarations in C language.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rocky2008 is offline Offline
9 posts
since Jun 2008
May 27th, 2009
0

Re: clrscr is usually given after declaration of variables. why ?

If the answer is not in your text book then you need a different book! But I'm sure its in the book, you just need to study the sections about C language program structure.
  1. // includes go here
  2. #include <stdio.h>
  3. ...
  4. int main(int argc, char* argv[])
  5. {
  6. // all variable declarations go here
  7. //
  8. // executable statements follow
  9. //
  10. {
  11. // new block, so more variables here
  12. // followed by executable statements
  13. } // end of block
  14. } // end of main() function
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
May 27th, 2009
0

Re: clrscr is usually given after declaration of variables. why ?

Click to Expand / Collapse  Quote originally posted by rocky2008 ...
thanks for your response. but can u please tell me why executable statements cant be given before variable declaration ?
Yes -- because the iso standards say so. I have read that this requirement is going to be relaxed in the next revision of the standards, but no compilers have implemented that yet (for obvious reasons)
Last edited by Ancient Dragon; May 27th, 2009 at 8:30 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
May 27th, 2009
0

Re: clrscr is usually given after declaration of variables. why ?

oh!! then does this problem arise because of the problem in allocating the required amount of memory by the compiler ?

Yes -- because the iso standards say so. I have read that this requirement is going to be relaxed in the next revision of the standards, but no compilers have implemented that yet (for obvious reasons)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rocky2008 is offline Offline
9 posts
since Jun 2008
May 27th, 2009
0

Re: clrscr is usually given after declaration of variables. why ?

Click to Expand / Collapse  Quote originally posted by rocky2008 ...
oh!! then does this problem arise because of the problem in allocating the required amount of memory by the compiler ?
Its not a problem. The C language was designed like that some 35+ years ago (officially 1972).
Last edited by Ancient Dragon; May 27th, 2009 at 8:50 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
May 27th, 2009
0

Re: clrscr is usually given after declaration of variables. why ?

hmmm... ok... thanks !!
Its not a problem. The C language was designed like that some 35+ years ago (officially 1972).
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rocky2008 is offline Offline
9 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: how to use C in dealing with windows
Next Thread in C Forum Timeline: Send and read info from a Serial Port using C?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC