Hello,
I am trying to incorporate the use of a batch file towards my program. For this I just want that after the program has starting running to send the file content's to stdin, in which case the program should do the rest? Is this possible, how so? Or should I be doing something completely different. Thanks.
flipjoebanana
0
Junior Poster in Training
Recommended Answers
Jump to PostI think you might be confused about the purpose of a batch file. Batch files are interpreted by the operating system -- not a program that you write. Yes, you can write a program that reads a batch file, but what will it do with it???
Jump to PostStep 1: create the text file that contains the commands
Step 2 write the c++ program using std::cin as you normally would. Here's an example
#include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { string line; while( cin >> line ) cout …
Jump to PostIf the file was included just open the file. If the file was not included, open stdin instead.
if (filename_entered) open file else open stdin end if
Jump to PostHe means if argc > 1 then you can assume argv[1] is the filename. But if argc == 0 or 1 then you can assume the filename was not entered on the command line like your example
int main(int argc, char* argv[]) { FILE* file = 0; …
Jump to PostYeah, that's what I meant... Esp since it was pseudo code, not C code.
All 19 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
flipjoebanana
0
Junior Poster in Training
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
flipjoebanana
0
Junior Poster in Training
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
flipjoebanana
0
Junior Poster in Training
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
flipjoebanana
0
Junior Poster in Training
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
flipjoebanana
0
Junior Poster in Training
stilllearning
148
Posting Whiz
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
flipjoebanana
0
Junior Poster in Training
stilllearning
148
Posting Whiz
flipjoebanana
0
Junior Poster in Training
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
stilllearning
148
Posting Whiz
flipjoebanana
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.