C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 25th, 2012, 09:42 PM
sandi.guha sandi.guha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Subhasgram,Kolkata,WB,IND
Posts: 13 sandi.guha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 4 sec
Reputation Power: 0
Send a message via Google Talk to sandi.guha
Facebook
Clrscr() executing problem in Dev C++ IDE

I'm using Dev C++ as IDE. everything is okay, environment is really good. But there is a problem executing clrscr() function. Where it's executed nothing happens, I mean screen don't getting cleared . Can You Hint me what I can do for that?

O.S---> Windows 7 x64
IDE---> DEV C++


Turbo C, Borland C don't support my config!

Reply With Quote
  #2  
Old August 25th, 2012, 10:13 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,383 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 20 h 49 m 30 sec
Reputation Power: 4080
How the heck did you even get your program to compile with Dev-C++? I think clrscr() is specific to turbo-C/Borland-C compilers only. Can you please show us the code you've got?
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Reply With Quote
  #3  
Old August 26th, 2012, 01:30 AM
sandi.guha sandi.guha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Subhasgram,Kolkata,WB,IND
Posts: 13 sandi.guha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 4 sec
Reputation Power: 0
Send a message via Google Talk to sandi.guha
Facebook
There's one tried..
Code:
#include<stdio.h>
#include<conio.>
int main()
{
    int ans;
    printf("Hello World\n");
    printf("ENTER <1> for clear the screen\nENTER <0> for       leave the message\n");
    scanf("%d",&ans);
    if(ans==1)
      clrscr();
    
printf("<PRESS ANY BUTTON TO EXIT>");
    getch();
}

I compiled that, no errors or warning. taking input normally, but after that printing same message while input is 1.
Is there any alternative for clrscr(). if there let me know, please, I need that for some other programs. Thnx..

Reply With Quote
  #4  
Old August 26th, 2012, 01:44 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,125 dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 16 h 57 m 4 sec
Reputation Power: 1949
MinGW gcc does come with a few conio functions implement with the console API.

Reply With Quote
  #5  
Old August 26th, 2012, 03:26 AM
sandi.guha sandi.guha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Subhasgram,Kolkata,WB,IND
Posts: 13 sandi.guha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 4 sec
Reputation Power: 0
Send a message via Google Talk to sandi.guha
Facebook
Quote:
Originally Posted by dwise1_aol
MinGW gcc does come with a few conio functions implement with the console API.

Will it support my config?? windows 7 x64.

Reply With Quote
  #6  
Old August 26th, 2012, 04:43 AM
clifford's Avatar
clifford clifford is offline
Contributing User
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 4,806 clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 17 h 19 m 38 sec
Reputation Power: 1800
It beats me why you would use an antique C++ IDE and MinGW distribution on Windows 7 x64.

Dev-C++ is only an IDE not a compiler. It is distributed with a compiler, but the distribution has not been maintained or updated for years and still comes with MinGW/GCC 3.4.2.

If you insist on using this set-up, it will be necessary for you to specify what version of Dev-C++ you are using, and if you have possibly manually updated the MinGW toolchain, what version of that you are using. It would also be helpful if you were to post the code you are trying to run and the build log.

However all that said you would do yourself a favour by using Microsoft Visual C++ 2010 Express. It is free, modern and more fully featured that your current antique software. Dev-C++ was a good choice up until about 2005 (when Microsoft first released Express Editions), but its interface design is inspired by VC++6 (circa 1996), and its GDB debugger integration was always buggy and rather limited to the point of absolute uselessness. It suffered friom having been written in Delphi which meant that those interested in using it (C++ developers) were not interested in or capable of developing and maintaining it.

With respect to clrscr() itself, it is not a standard function in C or C++ (because not all C/C++ targets have a "screen"), so is provided by a third-party or compiler supplied library. It is not clear therefore where you have obtained your particular clrscr() implementation from. MSDN describes two methods of clearing the "screen" or more accurately the console window in Windows console windows here. I suggest the second of the two methods where performance is an issue since the first invokes a cmd.exe process which is a bit heavyweight just to clear the screen! The second version may seem more complex, but will be faster. It is of course no more work for you since it is simply a copy and paste, and there after you can re-use that code in all your projects.

Reply With Quote
  #7  
Old August 26th, 2012, 07:20 AM
sandi.guha sandi.guha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Subhasgram,Kolkata,WB,IND
Posts: 13 sandi.guha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 4 sec
Reputation Power: 0
Send a message via Google Talk to sandi.guha
Facebook
Thumbs up

thanks for that recommendation
I got really helped!!

Reply With Quote
  #8  
Old August 27th, 2012, 07:16 AM
sandi.guha sandi.guha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Subhasgram,Kolkata,WB,IND
Posts: 13 sandi.guha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 4 sec
Reputation Power: 0
Send a message via Google Talk to sandi.guha
Facebook
Thumbs up

Quote:
Originally Posted by clifford
With respect to clrscr() itself, it is not a standard function in C or C++ (because not all C/C++ targets have a "screen"), so is provided by a third-party or compiler supplied library. It is not clear therefore where you have obtained your particular clrscr() implementation from. MSDN describes two methods of clearing the "screen" or more accurately the console window in Windows console windows here. I suggest the second of the two methods where performance is an issue since the first invokes a cmd.exe process which is a bit heavyweight just to clear the screen! The second version may seem more complex, but will be faster. It is of course no more work for you since it is simply a copy and paste, and there after you can re-use that code in all your projects.

As you suggested I tried this & compiled & result is much better than my expectation! Thanks again

Code:
#include<stdio.h>
#include<stdlib.h>
main()
{
     
     int a;
     printf("------------\n");
     printf("HELLO WORLD\n");
     printf("------------\n\n");
     printf("enter any number to clear screen:");
     scanf("%d",&a);
     
     if(a>-1)
     {
             system("cls");
     }
     return 0;
}

Reply With Quote
  #9  
Old August 29th, 2012, 12:45 PM
clifford's Avatar
clifford clifford is offline
Contributing User
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 4,806 clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 17 h 19 m 38 sec
Reputation Power: 1800
Quote:
Originally Posted by sandi.guha
Code:
     printf("enter any number to clear screen:");
     scanf("%d",&a);
     
     if(a>-1)
     {
        ...


Strictly speaking -1 is a number too, so you have asked for any number, but then excluded valid negative ones. Moreover if the user entered something not a number, "a" would contain an undetermined value because you never initialised it - it may not be less that one at all - you are trusting to luck with this code, and it may behave differently at any time.


Better practice is to check that scanf() performed the conversion successfully.
Code:
     printf("enter any number to clear screen:");
     converted = scanf("%d",&a);
     
     if( converted != 0 )
     {
        ...


and you should initialise the variable "a" in any case to reduce the possibility of falling into this trap in the future. Had you initialised it to zero for example, the code would not have worked and you'd have spotted the flaw. Had you initialised it to -1, it would have worked at least consistently albeit somewhat poor user interface design as I already described.

Reply With Quote
  #10  
Old August 29th, 2012, 01:01 PM
clifford's Avatar
clifford clifford is offline
Contributing User
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 4,806 clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 17 h 19 m 38 sec
Reputation Power: 1800
According to the Bloodshed Dev-C++ FAQ which has not been maintained for even longer then Dev-C++ itself, you have to explicitly link conio.o to get the conio functions. I

If that information is still correct, and your code compiled and linked, presumably you have done that. However as I recall, much of the conio.o shipped with Dev-C++ comprised of empty stubs that simply allowed legacy code to compile - not necessarily function correctly, and I think clrscr() is one of them.

You might try thisCONIO Dev-Pak for Dev-C++. Plenty of other useful packages for Dev-C++ are available at http://devpaks.org/

Reply With Quote
  #11  
Old August 29th, 2012, 09:59 PM
sandi.guha sandi.guha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Subhasgram,Kolkata,WB,IND
Posts: 13 sandi.guha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 4 sec
Reputation Power: 0
Send a message via Google Talk to sandi.guha
Facebook
Quote:
Originally Posted by clifford
According to the Bloodshed Dev-C++ FAQ which has not been maintained for even longer then Dev-C++ itself, you have to explicitly link conio.o to get the conio functions. I

If that information is still correct, and your code compiled and linked, presumably you have done that. However as I recall, much of the conio.o shipped with Dev-C++ comprised of empty stubs that simply allowed legacy code to compile - not necessarily function correctly, and I think clrscr() is one of them.

You might try thisCONIO Dev-Pak for Dev-C++. Plenty of other useful packages for Dev-C++ are available at http://devpaks.org/

Thanks again, man

Reply With Quote
  #12  
Old August 29th, 2012, 10:06 PM
sandi.guha sandi.guha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Subhasgram,Kolkata,WB,IND
Posts: 13 sandi.guha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 4 sec
Reputation Power: 0
Send a message via Google Talk to sandi.guha
Facebook
Quote:
Originally Posted by sandi.guha
Code:
#include<stdio.h>
#include<stdlib.h>
main()
{
     
     int a;
     printf("------------\n");
     printf("HELLO WORLD\n");
     printf("------------\n\n");
     printf("enter any number to clear screen:");
     scanf("%d",&a);
     
     if(a>-1)
     {
             system("cls");
     }
     return 0;
}


I took '-1' because usually we don't take negative numbers for an input from console. So I just did it. By the way, I wouldn't making a official program, so it's better to be simple. But you showed me that way, so it's really helpful. It's good to stick with you guys.

Reply With Quote
  #13  
Old August 30th, 2012, 02:26 PM
clifford's Avatar
clifford clifford is offline
Contributing User
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 4,806 clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 17 h 19 m 38 sec
Reputation Power: 1800
Quote:
Originally Posted by sandi.guha
I wouldn't making a official program, so it's better to be simple
There was nothing any more complex in my suggestion other than it was correct! Even with your solution, without initialising the variable 'a' it is just incorrect, so you have to change something to make it safe, so you may as well make it better at the same time.

All you code should be the best code it can be, even if it is prototype or experimental. The good habits you acquire will be come second nature and not a chore, so your production code will end up higher quality and less buggy.

The point is important; at some time you may be asked to make a critical business decision based on some experiential or prototype code. If the code is flawed, your decision may also be flawed.

Reply With Quote
  #14  
Old August 30th, 2012, 10:05 PM
sandi.guha sandi.guha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Subhasgram,Kolkata,WB,IND
Posts: 13 sandi.guha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 4 sec
Reputation Power: 0
Send a message via Google Talk to sandi.guha
Facebook
Smile

Would you have any suggestion for a good book for C briefly but easy learning. I'm following Tata McGrew Hill publication(Writer- E Balagurusamy)...& another is second Edition of C-Programming Language by K&R. EBG have good exercises & easy-to-hard program structure, but for only young & beginners.
I've completed full in basic programmings, like stop watch, clock, patterns,etc. Now I would like some hard, because I getting bored with some stupids who don't understand how to input or output. So I'm loosing my interest! Would you help? I'm trying to foot each step at a time & analysis the step before climbing another, it would be easy to climb the hill & enjoy the most. I'm convincing myself to give every possible energy to complete each analysis. My first goal is- complete C language, then C++. If God's sake & my processor are with me then I wanna make it quick but hardly. I don't wanna leave any crack behind for my future.

Earth might be end up this year or not, so I must continue this & continue it fast. You might be realized how height I wanna fly. I got my hand, skills, interest, full working keyboard, eyes, even balls to make it done. I wanna work, learn, spit the beans.
I wanna be good programmer, actually a well skilled programmer like you(mentioning Clifford). I want to learn C, C++, C#, JAVA, Python, Ruby step by step. Kindly help me... Just point me to right direction to achieve my goals. You got experience so share me some, let's see how much I can fly.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Clrscr() executing problem in Dev C++ IDE

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap