Solved

How to convert long to string and string to long in MS VC 2008 ?

Posted on 2010-11-29
2
385 Views
Last Modified: 2012-06-22
Hi experts!

I have a project in MS VC 2008 Win32 unmanage code. Look my code, it produce errors, but is good to find what I need. I need to convert lVar to (LPCTSTR) and later to convert (LPCTSTR) to long. Is that hard in C++ ? I want to do this using standard function without need to include additional files which I should deploy in customer computer.


       CStringArray csaFile1;
         csaFile1.SetSize(3,50);
            long lVal= 279362937;
        csaFile1.Add((LPCTSTR)lVal); // here produce error – need example code

            for(int x=0;x<csaFile1.GetSize();x++)
            {
                  
                  long hSetting=(long)csaFile1[x]; // here produce error – need example code

                  StradisDecoderSettings_Delete( (STRADISDECODERSETTINGS)hSetting);
               
            }
0
Comment
Question by:dvplayltd
2 Comments
 
LVL 30

Accepted Solution

by:
Zoppo earned 500 total points
ID: 34229365
Hi dvplayltd,

why do you want to use strings in a CStringArray here? You can simply use an array of 'long's. I.e. replace the 'CStringArray' with 'CArray<long,long>' and remove the '(LPCTSTR)' cast ...

Hope that helps,

ZOPPO
0
 

Author Closing Comment

by:dvplayltd
ID: 34229555
I’m not using is because I’m totally new in C, alt although  I have 10+ years in IT like programmer.
Thanks!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now