Thread: string manipulation question with strcpy and strcat and alike

  1. #1
    Registered User
    Join Date
    Jul 2004

    string manipulation question with strcpy and strcat and alike

    I have been trying to use lstrcpy and lstrcat functions to combine texts as shown below:
    BOOL PDFPRNINSTCALL PdfPrnInstCopyDriverFilesW(const WCHAR* pSourceFolder)
    	LPWSTR destFolder = L"E:\\test";
    	LPWSTR SdriverPath, SconfigFilePath, SlicenseFilePath;
    	LPWSTR DdriverPath, DconfigFilePath, DlicenseFilePath;
    	SdriverPath = SconfigFilePath = SlicenseFilePath = L"";
    	DdriverPath = DconfigFilePath = DlicenseFilePath = L"";
    	// Process the filenames to include directory + filename 
    	lstrcpy(SdriverPath, pSourceFolder);
    	lstrcpy(DdriverPath, destFolder);
    	wcout << SdriverPath << endl;
    	wcout << DdriverPath << endl;
    	return true;
    However, on the output window/debugger, I'm not seeing anything that SDriverPath nor DdriverPath is holding. Is there something that I've missed before using the string manipulation functions? Thanks.

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Toronto, ON
    Well since you didn't allocate any memory to your string pointers before trying to copy into them, it should be crashing all over the place.

  3. #3
    Join Date
    Oct 2007
    Inside my computer
    LPWSTR is not a type (string). It's a pointer. This is why I suggest avoiding using Microsoft typedefs.
    A pointer must point to an allocated buffer, as well, or you will most likely get an access violation.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed