Get premium membership and access questions with answers, video lessons as well as revision papers.

Most C++ compilers supply nonstandard functions that allow cursor positioning and the like. If a compiler supplies such functions, create a function called myclreol() using...

      

Most C++ compilers supply nonstandard functions that allow cursor positioning and the like. If a compiler supplies such functions, create a function called myclreol() using C++ language a function that clears the line from the current cursor position to the end of the line. However, give this function a parameter that specifies the number of character position to clear. If the parameter is not specified, automatically clear the entire line. Otherwise, clear only the number of character positions specified by the parameter.


  

Answers


Davis
since cursor positioning functions differ from compiler to compiler and environment to environment, only one possible solution is shown for borland C++ under a command-prompt environment.

#include
#include
using namespace std;
void myclreol(int len =- 1);
int main()
{
int i;
gotoxy(1, 1);
for(i=0; i<24; i++)
cout << "abcdefghijklmnopqrstuvwxyz1234567890\n";otoxy(1, 2);
myclreol();
gotoxy(1, 4);
myclreol(20);
return 0;
}
//clear to end line unless len parameter is specified.
void myclreol(int len)
{
int y;
x = wherex(); // get x position
y = wherey() // get y position
if(len== -1) len = 80-x;
int i = x;
for(; i<=len; i++) cout << ' ';
gotoxy(x, y); //reset the cursor
}

Githiari answered the question on May 31, 2018 at 17:39


Next: In the C++ standard library is the function strtol(), which has this prototype: long strtol|(const char*start, const **end, int base); The function cnverts the numeric string...
Previous: Describe the impact of competition policy on an organisation

View More Computer Studies Questions and Answers | Return to Questions Index


Learn High School English on YouTube

Related Questions