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
Solved

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

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

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 how to create, access, and change arrays 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.

809 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