473,473 Members | 1,576 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

what is piping in c++

5 New Member
can anyone explain me what is piping in C++ programming?

for example
invoice.exe < purchase.dat > statement.txt

do i replace that where all the cin statements? i created a text file called purchase.dat with values:

gameboy 149.99 1
ipod nano 220.99 2
DVD-player5 60.95 1
rubics cube 8.85 5

so i.e. below is some coding tat is in working progress. i able to make it tat it prints price, cost, quantity, and product id. i have to use piping. where do i put this statement: invoice.exe < purchase.dat > statement.txt
in the code?

Expand|Select|Wrap|Line Numbers
  1.            for (int i = 0; i <= maxitems; i++)
  2.            {
  3.                cout << "product: ";
  4.                getline(cin, productid);
  5.                cout << "quantity; ";
  6.                cin >> quantity;
  7.                cout << "price: ";
  8.                cin >> price;
  9.  
  10.                cost = quantity * price;
  11.                totalcost = totalcost + cost;     
  12.            cout << setw(34) << productid << setw(10) << quantity << setw(10) << price << setw(12) << cost << endl;           
  13.            } cout << "Total: " << totalcost << endl; 
May 27 '07 #1
3 4225
weaknessforcats
9,208 Recognized Expert Moderator Expert
What you have is not piping.

This example of yours:
invoice.exe < purchase.dat > statement.txt
is called redirection.

This is done on the command line where you execue yout program invoide.exe.

A command line argument of <purchase.dat redirects the input to your prgram so the keyboard (stdin) is replaced by the disc file purchase.dat. You need to change nothing in your code. Redirecting input just causes all of your cin statements to get input from the disc file rather than the keyboard.

Likewise, >statement.txt redirects the output (stdout) of your pogram from the monitor to the disc file statement.txt. Whatever cout displays on the screen is redirected to the disc file statement.txt instead.

Be aware than when you redirect output, your screen will be blank as all of the displays are written to a disc file.
May 27 '07 #2
noob2008
5 New Member
What you have is not piping.

This example of yours:


is called redirection.

This is done on the command line where you execue yout program invoide.exe.

A command line argument of <purchase.dat redirects the input to your prgram so the keyboard (stdin) is replaced by the disc file purchase.dat. You need to change nothing in your code. Redirecting input just causes all of your cin statements to get input from the disc file rather than the keyboard.

Likewise, >statement.txt redirects the output (stdout) of your pogram from the monitor to the disc file statement.txt. Whatever cout displays on the screen is redirected to the disc file statement.txt instead.

Be aware than when you redirect output, your screen will be blank as all of the displays are written to a disc file.
so how do i apply invoice.exe < purchase.dat > statement.txt
in the program?
May 28 '07 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
You do not apply this inside the program.

You specify this at the OS command prompt when you run your program.
May 28 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Apple Grew | last post by:
I want to develope a Winboard like application which will support Winboard protocol. For that I require to know how to handle piping in Python. I seperated out module popen2, but when I use...
5
by: red85 | last post by:
hello i have mysql 4.1 with win2000 SP3, i know that it is only an alpha and i don't know if someone else has already posted this problem: when i execute this sql UPDATE tableX SET...
4
by: christopher diggins | last post by:
I just wanted to share this technique for piping the cout from one function to the cin of another, using the pipe operator: #include <iostream> #include <sstream> using namespace std; ...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
3
by: Russ Schneider | last post by:
Is there an easy way to pipe a select statement's output to a file? -- http://www.sugapablo.com <--music ] http://www.sugapablo.net <--personal ] sugapablo@12jabber.com <--jabber IM ]...
2
by: moti | last post by:
I am a newbie to MySQL. I'm confused as to the piping syntax of SERVER in the User DSN in ODBC for a client PC. If I use an ip it does not work, probably because of a firewall. So I tried using...
1
by: AtoZ | last post by:
Hello, I'm looking for some experience translation between the software PDMS to Pro/ENGINEER ( Pro/PIPING ) and reverse. If some engineer know the solutions, their feedback will be very usefull...
4
by: samit | last post by:
I keen to persue coding like yahoo piping system which will include drag and drop and piping features
0
by: jsimps44 | last post by:
Hi, I'm fairly new to c, and very new to piping and file descriptors and can't seem to get past this problem. The piping is very much not working, and I can't figure out for the life of me why. Any...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.