Hi all,
I want to take the position of cursor from the command line and also want it to go to specific location. But I dont know how to accomplish that.
I have tried with cout.seekp () and cout.tellp (). But they didnt worked as I hoped. seekp () and tellp () did work with files. These are not working with command line and cout.tellp () is returning -1 showing that tellp () has failed. cout.seekp () is printing on the command line where the cursor, not taking it to the value I passed to seekp as argument.
The following code is the one I tried.
//17-july-09 14.02
#include <iostream>
using namespace std;
int main ()
{
int pos = 0;
cout << "Hello World!";
pos = cout.tellp (); //to get the position of cursor
cout << pos << endl; //this displays -1
cout.seekp (400); //want to take cursor to some other location (like 400)
cout << "$" << endl; //and print $ at that position
//but the cursor remains where it is and prints $ there, not at the specified location
return 0;
}
Any help would be appreciated.
I am using Windows Vista and MS Visual C++.