string manipulation question with strcpy and strcat and alike

This is a discussion on string manipulation question with strcpy and strcat and alike within the C++ Programming forums, part of the General Programming Boards category; I have been trying to use lstrcpy and lstrcat functions to combine texts as shown below: Code: BOOL PDFPRNINSTCALL PdfPrnInstCopyDriverFilesW(const ...

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    222

    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:
    Code:
    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
    Location
    Toronto, ON
    Posts
    3,545
    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
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,594
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21