Solved

CString::Left

Posted on 1998-04-10
2
513 Views
Last Modified: 2013-11-20
How do i solve this problem?
I need to extract the leftmost 5 characters of a CString.

CString szSvPath("D:\\AB\\CDE\\F.EXE") ;
CString szPath ;
szPath = szSvPath.Left[5] ;

error C2109: subscript requires array or pointer type
error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString (CString::*)(int)const ' (or there is no acceptable conversion)
Error executing cl.exe.
Creating browse info file...

0
Comment
Question by:engllf
2 Comments
 
LVL 5

Accepted Solution

by:
nebeker earned 20 total points
ID: 1317601
Just use () instead of []:

CString szSvPath("D:\\AB\\CDE\\F.EXE") ;
CString szPath ;
szPath = szSvPath.Left(5) ;


0
 

Author Comment

by:engllf
ID: 1317602
How careless of me.  I should have notice that.
Thanx.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Include multiple hostnames in this command? 3 55
Folder Comparison 12 54
Whole sheet autoscrub still needed 19 51
FizzBuzz challenge 9 82
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 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