Why my contents written to a file which is opened in binary is still a text

Hello,

I am facing a problem in writing my contents into a file in binary mode.
There is no exception or no error.
Can any one help me why the following code not able to write contents
in binary format to a file ?

 if (fp.Open("test.dat",CFile::modeCreate | CFile::modeReadWrite |
CFile::typeBinary | CFile::shareDenyNone)==NULL)
    return FALSE;
 else
 {
     char buff[20];
     strcpy(buff,"hello world");
     fp.Write(buff,strlen(buff));
}
 fp.Close();

I used both CFile and CStdioFile but even them i did not get success.
When i open the file i still see my contents in a text form.

Is it required to convert string to binary ? if it so pls help me
i don't no how to convert string to binary

I am not able to find where i am going wrong. please help

Thanks

Deepak


0
bsdeepu (16)
9/27/2003 6:13:39 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
621 Views

Similar Articles

[PageSpeed] 5

What you're getting is the correct behaviour.
What you mean by binary? you're expecting to see 0 and 1 in your output
file?

--
Elias
http://lgwm.org

"Deepak" <bsdeepu@hotmail.com> wrote in message
news:#RGe3uLhDHA.1964@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> I am facing a problem in writing my contents into a file in binary mode.
> There is no exception or no error.
> Can any one help me why the following code not able to write contents
> in binary format to a file ?
>
>  if (fp.Open("test.dat",CFile::modeCreate | CFile::modeReadWrite |
> CFile::typeBinary | CFile::shareDenyNone)==NULL)
>     return FALSE;
>  else
>  {
>      char buff[20];
>      strcpy(buff,"hello world");
>      fp.Write(buff,strlen(buff));
> }
>  fp.Close();
>
> I used both CFile and CStdioFile but even them i did not get success.
> When i open the file i still see my contents in a text form.
>
> Is it required to convert string to binary ? if it so pls help me
> i don't no how to convert string to binary
>
> I am not able to find where i am going wrong. please help
>
> Thanks
>
> Deepak
>
>


0
lallous (134)
9/27/2003 7:08:20 AM
On Sat, 27 Sep 2003 11:43:39 +0530, Deepak wrote:

>Can any one help me why the following code not able to write contents
>in binary format to a file ?

A file is an abstract container of data. Disregarding for a moment
issues like CR/LF translation, it doesn't matter what mode you write
the file in, the contents will be the same. If you use a text
application like notepad to read the file, you'll see text. If you use
a hex editor, you'll see the hex equivalent of that text.

What are you using to read the file ?

-- 
Bob Moore [WinSDK MVP]
http://www.mooremvp.freeserve.co.uk/
(this is a non-commercial site and does not accept advertising)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do not reply via email unless specifically requested to do so.
Unsolicited email is NOT welcome and will go unanswered.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0
bobm (116)
9/27/2003 11:52:17 AM
One legitimate binary representation of a string is a series of ASCII
characters stored by their byte values in ascending order of location in the
original string.  For this particular binary representation of a string
there is no difference between the binary and "text" format, they are the
same thing.  If you need to do a binary encoding of the text then your
strcpy() should be replaced with a function that encodes the source string
while copying it to buff.  Without more information on what you mean by
"binary format" it's hard to offer much advice.

"Deepak" <bsdeepu@hotmail.com> wrote in message
news:%23RGe3uLhDHA.1964@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> I am facing a problem in writing my contents into a file in binary mode.
> There is no exception or no error.
> Can any one help me why the following code not able to write contents
> in binary format to a file ?
>
>  if (fp.Open("test.dat",CFile::modeCreate | CFile::modeReadWrite |
> CFile::typeBinary | CFile::shareDenyNone)==NULL)
>     return FALSE;
>  else
>  {
>      char buff[20];
>      strcpy(buff,"hello world");
>      fp.Write(buff,strlen(buff));
> }
>  fp.Close();
>
> I used both CFile and CStdioFile but even them i did not get success.
> When i open the file i still see my contents in a text form.
>
> Is it required to convert string to binary ? if it so pls help me
> i don't no how to convert string to binary
>
> I am not able to find where i am going wrong. please help
>
> Thanks
>
> Deepak
>
>


0
mairda (55)
9/27/2003 11:04:50 PM
Reply:

Similar Artilces:

Adding Two Text Fields together
I'm using Office 2000. Is there a way to combined two "Text" cells into one cell? Ex. A1 text is "micro", A2 text is "soft, A3 = "microsoft". Thank you for your time. Hi! =A1&A2 OR =CONCATENATE(A1,A2) Biff >-----Original Message----- >I'm using Office 2000. Is there a way to combined two "Text" cells into one >cell? > >Ex. A1 text is "micro", A2 text is "soft, A3 = "microsoft". > >Thank you for your time. > >. > Audrey In A3 enter =A1 & A2 When happy, you can...

Move .pst File to New Location #2
If I move the .pst file to a new directory location , how do I get Outlook to find it? Is there a way to move the .pst without disabling all the message rules? The reason I ask is because I like to share .pst files between my laptop and desktop. The prob is the message rules use fully qualified path and file locations. My laptop has a business name user and therefore a different file location. So the two cannot share the message rules. I want to move the .pst file to something like C:\My Documents\OutlookData..., something thats the same for both pcs. Thanks, -Bob Outlook 2003 Dea...

opening the sorting window with VBA
Hi I have a worksheet containing 30 columns and 1000 rows I want to create a button that when user click on it, the range a9 to ac1009 is selected and that the sorting command windows pop up. (same as if you click DATA - SORT) So the user click the button, the range is selected automatically and the sorting window opens. After user make is own choice of sorting. I know how to do the first part but I am not able to open the sorting windows after the range is selected Hope my question is clear thanks Have you tried the macro recorder? Gord Dibben MS Excel MVP On Wed, 14 Jul 2010 0...

Title in Content Control disappears when grouping?
Hi, If I GROUP a portion of my document where there is a CONTENT CONTROL, its TITLE is not visible anymore. Why? I would like to avoid the user changing parts of my document, but still giving him the best clues where and what to type. thanks, Lauro When I looked at this a. I saw the same as you; b. I did not find a workaround. Non-response suggests none of the regular responders who are around knows either. > Why? You'd have to ask Microsoft (most if not all of the people here are volunteers, not their employees). It looks as if...

open a non-office file using cell data from excel
can I open a non-office file using cell data from excel. I want to use data calculated within excel, which I have then put into a string, to then be used to open the file, to which that string refers. Have a look in vba help for SHELL -- Don Guillett SalesAid Software dguillett1@austin.rr.com "dcauldwell" <dcauldwell@discussions.microsoft.com> wrote in message news:88B01B4E-7CFD-455D-B4AC-FD7E000F8B66@microsoft.com... > can I open a non-office file using cell data from excel. > I want to use data calculated within excel, which I have then put into a > string, to t...

table of content
Using styles (Heading 1, etc) in Word (any version) allows me to create a TOC very simply. I cannot find a way to create a table of content automatically in Publisher (2003), for instance by applying styles. Am I missing something or have they just left out this option? Don't want to create a TOC manually in a 200 page document.... TIA - Rob The bad news is you will have to create the TOC manually. Publisher is a page layout application. Word is better suited for what you are doing. -- Mary Sauer MS MVP http://office.microsoft.com/ http://www.mvps.org/msauer/ news://msnews.microsof...

2 User Database Question, does the opening order matter?
I have 2 PCs A and B and an application written in Access 2000Computer A has an MDE front end called Program.mde linked to the datacalled data.mdb. Both are in the same folder on the C driveComputer B has a mapped Drive to Computer A and Computer B has anexact copy of the MDE front end , again called Program.mde stored onits C Drive and linked to the data.mdb on Computer A using the mappeddriveIf i open up the MDE on computer A first , i cant open up the MDE oncomputer B, i just get the egg timer. This stays like this until ishutdown the MDE on computer A, then it will open upIs there a reason...

major increase in transaction log files
Hello, I've already browsed through the other postings and didn't find a match for our issue. we're running Exchange 2003 ent cluster BE with a single server FE for the gateway (all SP1). The front end is scanning AV and has intelligent message filtering and is enabled for circular logging (on it's own local drive). The back end does not have AV scanning or IMF, but does have full text indexing turned on the mail and public folders. Prior to turning on FTI, we noticed an extremely sharp increase in the amount of transaction logs & I can't seem to find a source ...

Formating a text string?
I use subscripting in Excel for text cells, but would like to subscript in a text string that includes numbers. For example, I need to subscript the "x" in Standard Deviation = 0.125 lbs/hr NOx. Is there a way of doing this? Hi select this character in the formula bar and goto format - cells -- Regards Frank Kabel Frankfurt, Germany "METCO1" <METCO1@discussions.microsoft.com> schrieb im Newsbeitrag news:59975300-0600-4A98-886F-52F735F87E12@microsoft.com... > I use subscripting in Excel for text cells, but would like to subscript in a > text string that in...

Problem Exporting Calendar contents with custom fields
I have created a customized form in MS Outlook Calendar to create appointments with more data that I need to track. When exporting a calendar to a CSV file, outlook only recognizes the main appointment fields, not my custom fields to export. I would like to see me fields export with the calendar. Any ideas? Thanks, Kris ...

Accessing an OST file
I have a user that is looking for a long lost email that she "hopes" she saved. Of course, she has many, many PST files. The email is not in any of those. There are 3 OST files in the default Outlook folder on her computer. Is there a way to open and search those files? I've done some research and have read that if the OST is orphaned, then you need to buy software that will let you convert the OST to a PST. That doesn't seem to be the case here, it is in her windows folder. Thanks "JohnB" <jbrigan@yahoo.com> wrote in message news:...

Middle mouse button does not always open in new tab anymore
Hi! I am experiencing the problem that when I click with the middle mouse button on a link (for example google search results) it does not always open it in a new tab anymore. In about 20% of the cases it takes over the current tab instead. The same problem is explained here in german: http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.de.internetexplorer&tid=cd463718-8df6-4ee4-9e8a-9ee527837f83&cat=&lang=de&cr=DE&sloc=&p=1 But since there was no answer found so far I decided to take it to the next level (english c...

keep formula delete contents
I'm trying to set up a template in Excel. I wish to keep the formula but delete contents, so i can us the same sheet again. Every formula evaluates to something -- a string, a number, an error, ... So you can't really delete the contents and still keep the formula. But you could modify the formula so that it returns an empty string ("") and that makes the cell look empty. You could modify the formula to look at the other cells it needs and if those are empty, then return that "" string. For example, if I had a formula that just added 12 to the valu...

CSV files
I try to open .CSV files from excel but they open in a single column. Help Tks, Gaby This can happen if the windows list separator (under control panel|regional settings) doesn't match the separator used in the .CSV file. For instance, with my USA settings, my windows list separator is a comma (,). If I import a file that uses a semicolon (;) as its separator, then all the data goes into a single column. I can either change my windows list separator (temporarily) and then reimport the .CSV file. Or I can select column A and do data|Text to columns and specify the matching separator ...

Can't open my Access files after conversion from Access 97 to Access 2003
Hi, After I converted my MS Access files from ver 97 to 2003, I cannot open them anymore. How can I resolve this problem? I run Windows XP Pro SP 3. Regards M Shafaat It isn't clear what's happening when you try ... more information, please. Are you attempting to open them with Access '97 or with Access 2003? Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a product or service herein does not constitute endorsement thereo...

Navigation Bars
I put Navigation bars on my publisher website document. When I try to publish to a file or to the web, the Navigation Bars do not appear on the page(s). How do I resolve this?? Answer found in the web group. DavidF "Tom Snyder" <Tom Snyder@discussions.microsoft.com> wrote in message news:7A55B689-FE9D-4E1E-9B6C-3ED571156D46@microsoft.com... >I put Navigation bars on my publisher website document. When I try to >publish > to a file or to the web, the Navigation Bars do not appear on the page(s). > How do I resolve this?? Tony, did you get an answer to this...

[OL2003] adding exchange account to profile by PRF file
Hi, a PRF file (as shown below) generates an exchange account within a separately generated profile. I would like to change the PRF file such that the exchange account is added to the already existing profile called "Outlook" such that there is no need to switch profiles all the time. What adjustments are needed? I think section 4 is the most important part. Thanks for your help. Best wishes, J. NB: XXXXXX denotes the account on the exchange server. In the code below it is the name of the profile generated by PRF, as well. ________________ ;Automatically generated PRF file from...

Text to Date Conversion
I am building an ACCESS form (Access 2003) that I imported an Excel table to build from. The form has a set of option buttons, that if selected, enter N/A into 4 text boxes. However, if the option buttons are not selected, the text boxes contain dates. The dates are selected from the Access Active Control calendar. Because the fields are either N/A (text) or a date, the Field Data Type on my table is text. If I change the Field Data Type from text to date - the N/A's disappear. Is there a Field Data Type that will accept both formats in one? If not, how do i convert the tex...

RMS *language.dat files
Hello, Any one of you still have a copy from a previous RMS version (1.2 or 1.3) of the *language.dat (poslanguage.dat, mgrlanguage.dat and qsadministratorlanguage.dat) which content more than 1 language (no matter which one, I just want to see the structure) so I could use it as a reference and therefore try to edit my file which content only English language in order to add 'French' but i`m just wondering which format to use? I do not want to buy from a reseller, I have already translated all the term in french and I only need to know what format I should use to add them a...

How do I transfer items in the Content Library in Publisher 2007?
I have a number of items in the Content Library in Publisher 2007 on my laptop which I would like to copy to the same program on my PC. I know I could copy and paste them, but there are quite a number and wondered if there is an easy way? Where is the file saved on the hard drive? What version Windows? The Application Data folders are hidden. Read the post from Amanda-BC-Can dated 11/22. She said she failed transferring the content library. If you succeed would you please post back and tell us the steps you used. Under Vista it is stored in this folder: C:\Users\<YOUR USER NAME>...

Importing .txt data files increases .xls file size
Am importing contact data from our Sales Management Software System into an Excel sheet. The Export process from the SMS system stores the data in a .txt file. Currently we only have about 1000 records, and the .txt file is about 87kb. When I import into Excel through the Import Wizard it adds 500k to the ..xls file size. Now when I split up the data into two alpha groups (A-M; N-Z) it doubles THAT size. Two questions: 1. Is there some way to not increase the file size (maybe during import?) 2. Is there a way to interact with the data from a separate worksheet altogether? -b First thin...

Copy Partial Cell Contents in Excel ?
Hi folks! I'm trying to figure out how to write a Macro in Excel that I can us to copy only a portion of data in a cell and paste that partial dat into an adjacent cell. Specifically, I am using Excel 2000 and tring t copy only the final dollar amount from entries such as the one below: 1@ $5.99 = $5.99 What I want is a pure dollar amount in the adjacent column so that can run totals of amounts spent. What I don't want is to have to cop and paste every entry manually. Can anyone help me with this -- Message posted from http://www.ExcelForum.com MadDubhgal, That cell should be ...

shared files problems
I have a file I share with some other people. I have it open almost all the time. Used to be when other people wanted into it, they could open a read-only copy. Then my hard drive blew up, and after fixing it, now they get an error message about not being able to open it. What do I change to get it back the way it was? Thanks how are they trying to open it? If it was a shortcut, then the link is gone and they need to re-connect to your computer. "russ b" wrote: > I have a file I share with some other people. I have it open almost all the > time. Us...

HELP! Split cell contents to new rows
I know how to split cell contents to columns, but how do you tell excel to take the cell contents and insert into new rows. Each name is separated by a comma and I need each name to appear in its own row beneath that cell. PLEASE HELP! Copy, paste special-transpose (now in columns). Data - Text to columns. Copy, paste special- transpose back to rows. -- Best Regards, Luke M "nyarce" <nyarce@discussions.microsoft.com> wrote in message news:E9E6CDF2-7A05-4337-B0DD-C88FCFF617B4@microsoft.com... >I know how to split cell contents to columns, but how do yo...

OUTLOOK 2000
No matter what I do I can't get outlook to open. It says - The Server containing the Global Address List is no longer available. Try again. But it doesn't give me an alternative server or tell me where to find one. I am trying for help this last time - after this I think I'll forget about trying to use Outlook Many thanks for your time Best wishes Teresa ...