Solved

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

Posted on 2010-11-29
2
396 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: 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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

705 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