473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

[VC++] How to Add text from TextBox to *.txt file

Hello everybody

My program displays common sayings in my language and it's using polish
specific characters. The program reads those sayings from text file
(*.txt) and everything is ok if I manually add some new sayings, save
them in Notepad and display in program with no problems. Those sayings
are organised in very simple way as lines:

[file]
Saying 1
Saying 2
<etc>
<here program should add new saying as a new line>
[/file]

However, if I use my option in my program "Add New Saying" then using
TextBox, how can I add new line in *.txt file where text (saying) is
taken from TextBox->Text property without losing polish characters? I
have used <fstreamlibrary and simple code below:

Expand|Select|Wrap|Line Numbers
  1. ofstream f_output("file.txt");
  2. char* txt = new char[TextBox->Text->Length + 1];
  3. for(int i=0; i<TextBox->Text->Length; i++) {
  4. txt[i] = Convert::ToChar(TextBox->Text[i]);
  5. }
  6. f_output << txt << endl;
  7. f_output.close();
  8. delete [] txt;
  9.  
Problem is that I am losing polish specific characters doing this. I
tried this with wchar_t but <fstreamis making mess with my file or i
still misses something.

Can you please help. Thanks =)
Aug 20 '08 #1
1 3207
>
Hi Ziko,

I guess you have to check about unicode stuff since you are having a
problem with polish characters. I don't think ofstream supports
unicode or "wide character set(?)". I guess this link may give you
some hints hopefully.

http://www.velocityreviews.com/forum...code-in-c.html

cheers,
AK
Thanks a lot. I will have a look at this link.

Regards
Aug 20 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Suresh Kumaran | last post by:
Hi All, Does anybody know the sytax in VB.NET to write the contents of a multiline text box to a text file? Appreciate help. Suresh
3
by: man | last post by:
Hello, At first I have to warn you - I'm a newbie so don't shout me down and don't beat me :). I have a few problems concerning programming using VC++ .NET Std 2003 (particularly Windows...
5
by: Ralph Krausse | last post by:
Hello all, New to .NET and was wondering if there is a classwizard to create code for message like VC++ has now, ie. automatically create code for KeyDown or MouseMove. Thanks Ralph
31
by: J.S. | last post by:
Let's say I have a text file with parameters like the following embedded in the text: @@Textbox1@@, @@Textbox2@@, etc. Is it possible to replace the parameters in the text file with values...
5
by: Steve S | last post by:
Heres what I want to do...User types into a texbox, clicks a button, the button saves that text to a file. The problem is that when I click the submit button, any changes made to the textbox are...
11
by: Code[R] | last post by:
hello all, i've a problem :s i've tried to convert a "system::string" (a textbox) to an "int" but i have only found a function to convert system::string to char and char to int :s : ...
0
by: Tom | last post by:
I have about 30 labels and textboxes on my web form and the user can input data into the text boxes. Then they click a button and a text file needs to be created. I can create the text file but how...
3
by: =?Utf-8?B?Q2luZHk=?= | last post by:
Hi all, I am trying to connect to a electromyograph machine for my thesis project, and I have a VB DDE client whose DDE functionality I want to convert to VC++. However I can't make my VC++...
2
by: Lee J | last post by:
Gang, I am self taught in C and fairly proficient for last 20 years. Don't program much, just little utilities for work. Been wanting to create windows forms and found MS VC++ Express. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.