Smart questions
Smart answers
Smart people
Join Tek-Tips Forums

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

mbkelly (TechnicalUser) (OP)
4 Jun 10 11:55
I am working a project in Visual Studio 2008, using C++ that is started using a custom wizard.  The wizard was provided by the vender and their starter code works fine.  It appears to be in .NET but I do not have sufficient knowledge to determine the exact style in terms of MFC, CLR, etc.  I need to grab some data and write it to a file.  I'll start with a text file, then add a binary file.  Here are the relevant lines of the nonsense I have so far.

int number1 = 11;
int number2 = 22;

CString tempBuffer;
TCHAR pfileName = _T("C:\temp.txt");
CStiolFile f1;
f1.Open( pFileName, Cfile::modeCreate | <and someother options>);

tembBuffer = "\nnumber1:" + number1 + " number2" + number2;
f1.WriteWtring( tempBuffer );

This code writes "number is" but does not get the value.

I tried:

tempBuffer.Format(" number1 is %d", number1 );

But then the compiler complained about the line several lines up:
TCHAR pfileName = _T("C:\temp.txt");
saying T is an unrecognized character escape sequence.

In summary, I just need to open a file and write a bunch of values to it.
It always seems that the easy and simple stuff is so hard to find. But maybe I'm barking up the wrong tree.  Give me some direction and I will be glad to use a different concept that is more appropriate.

Thank you
ArkM (IS/IT--Management)
4 Jun 10 12:26


That's all. Remember string literal syntax...
mbkelly (TechnicalUser) (OP)
4 Jun 10 13:10
Thanks for taking the time to respond, but that's not my problem.  Obviously I left out the \\ when writing the post.
The problem is this:
tembBuffer = "\nnumber1:" + number1 + " number2" + number2;
How do I get the values of the numbers into the string so they can be written to the file?

mbkelly (TechnicalUser) (OP)
4 Jun 10 14:55
After more searches I finally found I can do this:
int temp_data = 13;
CString temp_string;
temp_string.Format( _T("\ntemp_data is: %d", temp_data ));
f1.WriteString( temp_string );

But when I look in the file, it contains:

temp_data is 899889814

I don't know how 13 translates to that, but it appears there is something I have omitted.

Second question:  Is this the best basic technique to use for going forward within MFC when using Visual Studio C++, or maybe C#?

xwb (Programmer)
5 Jun 10 13:57


temp_string.Format( _T("\ntemp_data is: %d"), temp_data );
mbkelly (TechnicalUser) (OP)
7 Jun 10 8:05
Thank you, I have it working now.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close