i'n a beginners but this is the big problem for me

why the screen is not clear....even though i used system("cls");.....like void does nothing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream>
#include<stdlib.h>
using namespace std;
void clear();
int main(){

cout<<"this line need to be cleared";
void clear();


}
void clear()
{
	system("cls");
}
Because the function that you want to call is "clear();" void is to indicates that this function doesn't return anything, it should not be a part of the function call.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<iostream>
#include<stdlib.h>
using namespace std;
void clear();

int main(){
    cout<<"this line need to be cleared";
    clear();
}

void clear()
{
	system("cls");
}
Last edited on
or maybe you wrong....even though i use int clear()....the same thing still happens
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream>
#include<stdlib.h>
using namespace std;
int clear();
int main(){

cout<<"this line need to be cleared";
int clear();


}
int clear()
{
	system("cls");
}
Last edited on
now...i do not use system("cls") anymore,,,,but nothing happens in " int clear() "...check this out.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<iostream>
#include<stdlib.h>
using namespace std;
int clear();
int main(){

cout<<"this line need to be cleared";
int clear();


}
int clear()
{	
	cout<<"ok ";
	
}
Both
 
int clear();
and
 
void clear();
are function declarations. That is, they tell the compiler that the function exists, and what it looks like, to put it very loosely.

When you want to actually call the function, so that it is executed, just write:

 
    clear();
Last edited on
You again Chervil...you just say my night.....REALLY REALLY REALLY APRECIATE THAT...THANKS
Last edited on
Topic archived. No new replies allowed.