| | |
how to open a file after running the program
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
•
•
>Of course the user could always use Notepad to view the file.
Oddly enough, my test call for that function was:
C++ Syntax (Toggle Plain Text)
showFile ( "notepad.exe", "C:\\narue_is_kewl.txt" );
now i have another problem...i want to open file with some other programs...like MS word,MS excel etc...
so what should be the program name (eg notepad.exe) for them....how can i find the exact name for all the text reading programs in my laptop..(wordpad,MS excel,MS access,MS word etc..)
Life is about being happy...
So you just want to open it.
Then I guess the easiest, although not necessarily the best way, would be to call it from system.
Then I guess the easiest, although not necessarily the best way, would be to call it from system.
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main() { system("C:/test.xls"); //path to excel file }
Last edited by iamthwee; Jan 6th, 2008 at 7:19 am.
*Voted best profile in the world*
•
•
•
•
So you just want to open it.
Then I guess the easiest, although not necessarily the best way, would be to call it from system.
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main() { system("C:/test.xls"); //path to excel file }
c++ Syntax (Toggle Plain Text)
#include<iostream> #include<fstream> using namespace std; int main() { ofstream fout("excel.csv"); int a[20]; for(int i=0 ; i<20 ; i++) { srand(i); a[i]=rand()%100; fout<<a[i]<<","; if(i==10) fout<<"\n"; } fout.close(); system(("excel.csv")); return 0; }
i know that excel files need to be saved in CSV format...(i learned it here in other thread) now as u can see that i have just mentioned the filename in system call...while you wrote the path of the file...
but my program is still working..the file is getting opened on running the program..but how?
my program is saved in F drive and i haven't mentioned the file path..but it is in the same folder where the program is saved...may be that's why it is working without filepath..please clearify!
and my other question is that it doesn't require the name of the program in which the file has to be opened..as Naure told me to write the name of the program (see older posts) for example notepad.exe ? So i think it opens the file in the default program attached to that particular format of file or extension..is it correct?
Life is about being happy...
what do you mean by not properly?
are you talking about seed i ?? well i wrote this program just to learn about writing to excel and opening it...i used rand function to save myself from typing and initializing the array, nothing else.
I should have used the time seed instead to generate random numbers..
is it that what you want to say??
are you talking about seed i ?? well i wrote this program just to learn about writing to excel and opening it...i used rand function to save myself from typing and initializing the array, nothing else.
I should have used the time seed instead to generate random numbers..
is it that what you want to say??
Life is about being happy...
suggestions:
1. move line 10 srand() up above the loop. It should only be called once within the lifetime of the program. most people call it like this:
2. why do you need the array?
1. move line 10 srand() up above the loop. It should only be called once within the lifetime of the program. most people call it like this:
srand( time(0) ); 2. why do you need the array?
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- Can seem to open my file (C++)
- Button Click Opens new file/program (VB.NET)
- IE does not open *any* online web pages (Web Browsers)
- removed spyware now IE wont work (Viruses, Spyware and other Nasties)
- Another Program Launching mine (C++)
- can't open regedit (Viruses, Spyware and other Nasties)
- Can't open any programs (Viruses, Spyware and other Nasties)
- Nothing will open in my Internet explorer (Web Browsers)
- End program when logging off (Windows NT / 2000 / XP)
- file unable to open (C++)
Other Threads in the C++ Forum
- Previous Thread: adding & subtracting objects from a list
- Next Thread: Please advise
Views: 1714 | Replies: 18
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets







