Solved

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

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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 how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

832 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