open file with arbitrary name

From: David Jones (davidhere401_at_hotmail.com)
Date: 01/26/04


Date: Mon, 26 Jan 2004 14:20:40 -0500

I'm writing a function to save data in the form of numbers(double). what I
do is I use a dialog box to get a filename and then try to save the data to
that file. but I get a problem because I don't think that myFile.open()
likes the type that I pass to it to give it the filename and am not sure how
to fix it. I put the basic code below but its not compilable because the
GetDlgItemText is really used in a message handler that goes with windows
programming. It's called by the dialogBox.

char fileName[20];
GetDlgItemText(hWnd, IDC_EDIT1, (LPTSTR) fileName, 20);

ofstream myFile;
myFile.open(fileName, ios::out);

if (! myFile) {
                        MessageBox(NULL, NULL, "WHATEVER", MB_OK);
                   }

//LOAD DATA FROM FILE HERE

myFile.close();

I simply think don't know what type to use for fileName. When I replace
filename with a constant like "file.txt" it works just fine.
thanks
dave



Relevant Pages

  • Re: Nested For and While Statements
    ... writing some pseudocode. ... listtemp = doctemp ... day + hour + Stotalclass + classsum ...
    (comp.lang.python)
  • Re: MIME attachments, and alternatives
    ... bill ramsay writes: ... > I am writing a program that sends simple text files to a remote ... > in a directory called attachments. ... is guessing the mime type from the filename ...
    (comp.lang.python)
  • Re: creating filename using variable values (with save)
    ... On a related note, the data I'll be writing is a structure with fields containing very large matrices of numeric data, which will get processed. ... Is saving this as a .mat file and loading it for later processing the best way? ... The MATLAB help seems to say you CAN pass save a variable as filename, probably best to use the functional form though: ...
    (comp.soft-sys.matlab)
  • Re: perl open function for size bigger than 2 Gig
    ... I still have trouble with writing a big file. ... want to check whether the open command succeeded, ... Does it work when you specify a filename that doesn't exist, ... > figure out why echo doesn't work or any other program to try. ...
    (comp.lang.perl.misc)
  • Re: Wanted: Word Hyperlinks to Mapped Drive, NOT to UNC
    ... >I realize the steps are fairly simple but based on my past experience ... >I'm in the process of writing up this issue and I'll post back once I ... that's the equivalent of Insert Hyperlink, ... simply text containing the full filename. ...
    (microsoft.public.word.application.errors)