Start New Discussion within our Software Development Community

I completely rewrote the Stub i was writing because my VB -> C++ was shocking.

VB Version:

Public Function TempPath() As String
    Dim WindirS As String * 255
    Dim TEMP
    TEMP = GetTempPath(255, WindirS)
    TempPath = Left(WindirS, TEMP)
End Function

The Left function returns a specified number of characters from the left side of a string.

Tip: Use the Len function to find the number of characters in a string.

Tip: Also look at the Right function.
Syntax

Left(string,length)

--------------------------------------------------------------------------------

I tryed doing it but i think i did it horribly wrong

void TempPath()
{
	char WindirS[255], TEMP;

	TEMP = GetTempPath(255, WindirS);
	TempPath = std::left(TEMP);// <---- this line
}

Error:

C:\Program Files\Microsoft Visual Studio\MyProjects\szStub\Main.cpp(23) : error C2664: 'left' : cannot convert parameter 1 from 'char' to 'class std::ios_base &'
        A reference that is not to 'const' cannot be bound to a non-lvalue

So yip, not sure what do to lol

Can edit above post sorry :(

Example of VB =

dim txt
txt="This is a beautiful day!"
document.write(Left(txt,11))

Output:

This is a b
This question has already been answered. Start a new discussion instead.