How can I open another .exe file in my DOS-program.
This is a discussion on opening a file in DOS within the A Brief History of Cprogramming.com forums, part of the Community Boards category; How can I open another .exe file in my DOS-program....
How can I open another .exe file in my DOS-program.
do you mean execute another exe or open it and view the content?
system("MyProgram.exe"); will execute it, also look into the various spawn and exec functions
otherwise:
This code reads the contents of a file
there are numerous other ways to read from a file but this is just one.Code:FILE *fptr; //file pointer fptr=fopen("MyFile.txt", "rb"); //open file as read binary mode while(YourMomIsFat) //usually check for eof or something { variable=fgetc(fptr); //read a byte UseVariableInSomeWay(); }
mooooo@cooowwww.com
in c++
Code:#include <iostream> #include <fstream> ... ofstream fout=("c:\\whatever\\new.txt"); if (!fout.is_open()) { cerr<<"Oops, file can't be created or opened."<<endl; exit(1); } fout<<"Some Text"<<endl; fout.close(); ifstream fin=("c:\\whatever\\new.txt"); if (!fin.is_open()) { cerr<<"Oops, file can't be opened."<<endl; } fin>>someText; cout<<someText; fin.close(); ...
PHP and XML
Let's talk about SAX
In English:
One line of code, the obvious best choiceCode:Open file.txt and read it.
There are standard functions in C. All compilers are supposed to have them. Same deal with C++.
well duh!!! But thats not why hes asking, you cant expect someone to know all the standard c/c++ functions and understand exactly how to use them.
mooooo@cooowwww.com
Thanks people....
I use Borland 5.02
http://www.rt.com/man/execl.3.html
There are several functions that allow you to excecute a file and are better to use than system("whatever.exe").
Do I hear an echo in here? Also, dont trust that include file, I dont think its dos standard.
True, but I'd say that most people who have been programming for a while know a pretty good deal of them (if not all of them) and how to use those that they know of. The c standard library isn't a very big library.Originally posted by thedumbmutt
well duh!!! But thats not why hes asking, you cant expect someone to know all the standard c/c++ functions and understand exactly how to use them.
But he did ask, so that would suggest he needed some sort of help, examples are nice sometimes.
mooooo@cooowwww.com
You're good at picking nicknames, I'll give you that.