I am trying to learn C++ and making some assignments to gain more knowledge. Found this challenge: Make a graphical transmitter application through which a process passes the content of a file, line by line, to a son process. A line is transmitted from 3 in 3 seconds. The receiving process will receive this information and display it in a multi line box. Upon completion, the receiver process will send the number of read lines, the number of words and the number of punctuation marks to the parent (transmitter application). For communication, the clipboard will be used.
The issue is that i have no idea how to start this, can you please help me out and point me some directions or information on how to start building this application and complete it? Thanks in advance for your guidance.
start by doing the bits you know how to do, then build on those using some research and examples to meet your goals.
forget communications, can you open a file, read it line by line? Write code that does just that much. Then write another program that can grab data off the clipboard and display that. There should be many examples of this out there. Then wrap up by using what you learned so far, and some documentation searching or web searching on putting the parent's data to the clipboard. Test this by writing 1 line from the parent to the clipboard, then just hitting paste in something line notepad. Then build up from there, figure out how to use all these bits to let 2 programs talk to each other --- the parent sends, the child reads and puts a receipt on the clipboard, the parent was waiting on that, finds it and repeats until all lines are sent... once all that works you can play with the multi line text box widget to polish it up and complete...
Ive not used the clipboard this way, but I expect telling the parent you read the data is critical to success, so you don't overwrite a line before the child has grabbed it... that isnt obvious in your description but as far as I know about how the clipboard works, it only holds 1 item at a time (?).
So far i managed to make this app which helps me to keep track of the number of appearances for the vocals and consonants, but i am still miles away from my challenge
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream f("d:\\litere1.txt");
if (!f)
throw new exception("Error opening input file\n");
int a, e, i, o, u, c; //the number of appearances of each vocal and consonant
a=e=i=o=u=c=0;
char x;
while (!f.eof())
{
f >> x;
switch (x)
{
case 'a':
case 'A': {a++;break;}
case 'e':
case 'E': {e++;break;}
case 'i':
case 'I': {i++;break;}
case 'o':
case 'O': {o++;break;}
case 'u':
case 'U': {u++;break;}
default:
if ((x > 'a'&&x <= 'z') || (x > 'A'&&x <= 'Z'))
c++;
};
}
f.close();
ofstream g("d:\\litere2.txt"); if (!g)
throw new exception("Error opening output file\n");
g << "Appearances of a|A: " << a << '\n';
g << "Appearances of e|E: " << e << '\n';
g << "Appearances of i|I: " << i << '\n';
g << "Appearances of o|O: " << o << '\n';
g << "Appearances of u|U: " << u << '\n';
g << "Consonant appearances" << c << '\n';
Next you need to compute the velocity of the rocket ship.
...
Ok, I am being a little funny, but I can't begin to relate the above code to your original problem statement. Its well done (maybe not the slickest but its clean and makes good use of switch) and looks like it would count things for you, but I don't see how to connect counting the letters to sending lines to another program.