Solved

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

Posted on 2010-11-29
2
392 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 31

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

733 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