|
this is enough ,thank you very much
|
|
|
|
|
as you use C++, use C++ 'til the end...
prefer std::fstream to manage files that the old C functions like fopen() and fprintf().
std::ofstream myFile("C:\\a.txt");
myFile << (LPCSTR)myCString;
myFile.close();
also, ,be careful when writing file paths... use the double \\ !!!
|
|
|
|
|
Thank you, I'll follow the rule in the future
|
|
|
|
|
ewighell wrote: if writing to a MS Excel file is as simple, I would rather learn how to write to a Excel file.
Its not as simple as writing to a text file, but you can find plenty of examples and documentation by googling for Excel Automation. I recommend being at least vaguely familiar with COM before trying to jump through the Office-Automation hoops, though.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Thank you very much!!!
I am happy that I have never planned to become a software engineering.
|
|
|
|
|
If you are using MFC then use the CStdioFile::WriteString method.
CStdioFile file;<br />
file.Open (...);<br />
file.WriteString (myString);<br />
file.Close ();
|
|
|
|
|
but it seems that I can only write strings in English into the file. it fails when it comes to Chinese characters.
by the way, UNICODE has been defined in my program.
does any body know why and how to fix it?
Thank you very much!!!
-------------------
I am learning C++ and English
|
|
|
|
|
You can use CFile with CArchive for wrote to txt file
|
|
|
|
|
Hello
I need to ask a Yes or No question in a message box . like
Application->MessageBoxA()
but with two buttons : Yes and No
I am working with Borland C++Builder.
thanks
|
|
|
|
|
Specify MB_YESNO for uType parameter of the MessageBox function. More info here[^]
|
|
|
|
|
|
If you search for MessageBox on the msdn.microsoft.com website you will see that it takes four input parameters like this:
MessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
HWND is the window handle
lpText is the text that is going to ask the question
lpCaption is the title of the message box
uType is the type of box (for a yes/no box set it to MB_YESNO in visual studio)
make sure you include the required header file Windows.h for the defines
Chipper Martin
|
|
|
|
|
if(AfxMessageBox (_T("Question"),MB_YESNO)==IDYES)<br />
{<br />
}<br />
else<br />
{<br />
}
|
|
|
|
|
Hi,
Does anyone know of a free tool I can use to convert a binary data file into an array of literal hex values, so as to be able to embed the data of the file in my source code?
Joel Holdsworth
|
|
|
|
|
You'd be better off adding the binary data to the EXE as a resource and using the FindResource , LoadResource and LockResource functions to access it in place.
Steve
|
|
|
|
|
True enough... when you're windows programming, not working on an embedded system!
Joel Holdsworth
|
|
|
|
|
So you're not targeting Windows? If this is the case it would have been a good idea to mention this as this is a Windows programming site and unless otherwise informed people will assume you're programming for Windows.
If you're targeting Windows there will little difference. The data is the same size regardless. If you turn it into hex literals the compiler turns it back into raw data when it compiles it. If you attach it as a resource the actual raw data is in the EXE instead if the same data reconstructed by the compiler.
If you're not programming Windows your toolset and platform may well provide a similar feature.
Steve
|
|
|
|
|
Just write your own using base64 encoding and something like this[^]
led mike
|
|
|
|
|
int c, x=0; while((c=getchar())!=EOF){if(x++==8)x=0,putchar('\n'); printf("\x%02X, ",c);}
Run it with: "appname < datafile.bin > codefile.cpp" It's C but I wrote it like it was Perl
|
|
|
|
|
Hi,
I need to write a MFC application that views MSOffice documents. I would like to know if some of you have already done some thing like this and what would be the best way to accomplish it.
I've found some companies selling OCX components to do that. Does anyone tryed those components? Did you like them? What component would you recommend me?
Thanks in advance,
Vinicius
|
|
|
|
|
You have to search for automation. For example Word automation or Excell automation. You should be able to find a lot of resources about that with google. This website has also some resources about automation.
|
|
|
|
|
What MSOffice documents in particular are you wanting to read? You can use automation to do most tasks, but you would always need the relevent MS program to be installed on the machine. Ie. if you want to read .xls file, you will need to have MS Excel installed.
You could however attempt to read the file directly, for this you would need to know exactly how the file is structured. Try searching for "Compound document" along with the filetype.
|
|
|
|
|
Basically, I intend to read Word and Excel documents and I believe that in most cases I will have MSOffice installed on the machine.
Vinicius
|
|
|
|
|
waldermort wrote: You can use automation to do most tasks, but you would always need the relevent MS program to be installed on the mach
I am not sure but I don't think this is true. You can simply provide a dll with your program and register it. But I don't remember which one.
|
|
|
|
|