473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Clearing the console screen in gcc

1
Hi,

How do I clear the console screen in gcc compiler.
It does not accept clrscr() or system(cls);
I dont want to print blank lines or use putchar(' \f');
Is there any defined function in gcc like clrscr() to clear the console?
Sep 6 '06 #1
6 44043
Banfa
9,065 Expert Mod 8TB
My question would be why would you want to. Most people using the console would be what I would term advanced users. If they want the console cleared before running you program then they are capable of doing it themselves.

I have seen a fair number of posts on usenet breating programs that clear the console before running especially if they don't restore it when they finish (which is much harder to do).
Sep 6 '06 #2
use system(clear)
Sep 7 '06 #3
koder
23
i happen to follow the advice and i have ran this program and got the following errors

#include<stdio.h>

main()
{
printf("hai");
system(clear);
}

d1.c: In function `main':
d1.c:6: `clear' undeclared (first use in this function)
d1.c:6: (Each undeclared identifier is reported only once
d1.c:6: for each function it appears in.)

how it can happen?
Sep 7 '06 #4
First of all you didn't include the header file for the API "system". I think you don't know the prototype of API "system". The prototype of system is

int system(const char *string);

And in the program you written above, you passed just clear but not as a string. So try the following code

#include<stdio.h>
#include<stdlib.h>

main()
{
printf("hai");
system("clear");
}


See the man page of every API before using. It will help in self learning.
Sep 7 '06 #5
dude u roocks...it wrks and was a superb reply...
thanks a lot for ur kind help..

Thanks
sanju
Nov 18 '10 #6
system("cls") will work for clrscr()
stdlib.h is to be included
May 15 '15 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ishwor | last post by:
Hi i use IDLE to code Python in my machine. What i haven't been able to do is call an in-built function called clear()/cls()/clr() because it mightn't exist. so what i did is coded my own function...
5
by: phickman | last post by:
Hi all. After several searches using Google, I had just about given up on finding a way to clear the console Window. After spending the past week learning assembly language and writing a small...
2
by: Tee | last post by:
Hi, I am using System.Diagnostics.Process to start a console application, but I don't want the user to see a "black" screen when the console application is running, how can I hide it? Thanks,...
2
by: 28tommy | last post by:
Hi there, I'm doing some TELNET and FTP sessions with my scripts. I need to redirect all the output (and not just what I print) to an output file, but still be able to see the session in process...
2
by: sherifffruitfly | last post by:
Hi, I'm just learning cpp, and something I've had on my mind for awhile is to make a little "virtual console screen" class structure. In it I want to be able to do "text animation" - moving...
1
by: Shane | last post by:
This question must come up a bit, but I cant find a solution to the question. The nearest Ive found for clearing a dos console is at the following http://support.microsoft.com/kb/q99261/ But, it...
0
by: pangsans | last post by:
hello in c++ u can clear the screen using the clrscr() function!wat does one do in java to clear the screen before displaying the output?
0
by: alokranjan26 | last post by:
HI all, I just want to know how can i clear a console screen in using c# , can some one also tell in it can be done using API. Regards, Alok Ranjan
11
by: telephone | last post by:
can we write a c code in turboc++(3.0 dos version) which will print the numbers consequently from 0 to 1000 on the console screen or output screen provided that we can use only the following...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.