473,789 Members | 3,060 Online
Bytes | Software Development & Data Engineering Community
+ 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 4245
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.tx t 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.tx t 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
1876
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 fileObject.readline() then it halts the program if the sub-process is waiting for user input; will executing the readline() part in a seperate thread be helpful? My target platform is Windows. Links to helpful web resources and sample Python codes...
5
4014
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 fieldX=valueX WHERE id IN (SELECT tX.id FROM tableX AS tX WHERE tX.fieldY=valueY AND filedZ=valueZ);
4
2542
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; typedef void(*procedure)();
121
10183
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 support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
3
21403
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 ] ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives?
2
3671
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 named pipes and nothing seems to work. I am running MySQL on a windows xp and all the client PCs are on xp too. Named Pipes is checked as well as Enable named pipes and Socket/pipe name, which is MySQL.
1
3060
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 ! Thank You Antony AtoZ
4
1322
by: samit | last post by:
I keen to persue coding like yahoo piping system which will include drag and drop and piping features
0
1464
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 help at all would be greatly appreciated. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <signal.h>
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5417
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.