[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Writing a simple program

Posted on 2000-02-25
10
Medium Priority
?
200 Views
Last Modified: 2012-05-04
I was wondering if someone could tell me how, in C or C++, that i could print stuff from a program directly to the cursor. i know how to print things to .txt but no to the cursor in real time
Can anyone help
Thanks
0
Comment
Question by:ciaran_g
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3
10 Comments
 

Expert Comment

by:serp_mage
ID: 2560543
If "to the cursor" means to the command line, or to a DOS window when using Visual C++, you have a couple options.  You can do the C thing:
e.g.,
#include <stdio.h>
.. . .
printf("what's up?\n");    

or you can do the C++ thing,
#include <iostream.h>  //might not need the ".h" suffix
.. . .
cout << "what's up?\n";
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2560671
What is "to the cursor"?
serp_mage's or what?
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2560772
serp_mage seems to have answered it .. suggest you put it up as an answer.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 22

Expert Comment

by:nietod
ID: 2560821
And what OS is this for? and What compiler are you using?
0
 
LVL 1

Expert Comment

by:nutsnuts
ID: 2561135
If serp_mage has answered what "to the cursor" is, so I think you can put the output to a file like this:

#include <stdio.h>

   FILE *stream;
   int    i = 10;
   double fp = 1.5;
   char   s[] = "this is a string";
   char   c = '\n';

   stream = fopen( "output.txt", "w" );
   fprintf( stream, "%s%c", s, c );
   fprintf( stream, "%d\n", i );
   fprintf( stream, "%f\n", fp );
   fclose( stream );

That's it.
0
 

Author Comment

by:ciaran_g
ID: 2562453
Adjusted points to 100
0
 

Author Comment

by:ciaran_g
ID: 2562454
Sorry guys, i didn't make myself clear, say if i had a flashing cursor in a program, i minimse that, run my program and my program would print stuff out to that flashing cursor. maybe put a delay on my program and then get my program to print to wherever the cursor was flashing. i am using borland C++ 4.5. and i want to print stuff to a windows program (to where the cursor is flashing)
Thanks
0
 
LVL 22

Accepted Solution

by:
nietod earned 400 total points
ID: 2562631
Are you saying you want to "fake" keystrokes.  i.e. have our progream make the computer act like keys were types by the user?

The easiest way to do this is use keybd_event().  However, it only works if the program you want to have "receive" the keystrokes has the focus.  If the program doesn't have the focus, you can set the program WM_KEYDOWN and WM_KEYUP messages using sendmessage, however this tends to be harder to do and less reliable.
0
 

Author Comment

by:ciaran_g
ID: 2562797
That just what i want, thats great, thanks a lot, really appreciate it
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2563222
Shame you didn't say that in the first place :-).
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question