Ok i finished porting the VB code to c++ but ive hit a wall, it had 49 errors and i solved as many as i could but now im stuck

#include <windows.h>
#include <iostream>

#pragma comment(linker,"/FILEALIGN:0x200 /MERGE:.data=.text /MERGE:.rdata=.text /SECTION:.text,EWR /IGNORE:4078")

void IsValidChar(char sChar);
void GetRandomNumberInRange(int iLower, int iUpper);
void GetRandomNumber();

char exeData, DecString, CurrentCHAR, CHARCrypted;
char FinalSTR, Spliting, szStr, szStr2, szStr3;
bool CryptER;

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

	TEMP = GetTempPath(255, WindirS);
	TempPath = std::left(WindirS, TEMP);
}

void GenerateKey(int iLower, int iUpper)
{
	char szKey, szChar, Chr, sChar;
	int iLen, iLoop;

	iLen = GetRandomNumberInRange(iLower, iUpper);

	for(iLoop = 1; iLoop != iLen; iLen++)
	{

	Retry:

	sChar = Chr(GetRandomNumber());
	
	while(sChar = Chr(34))
	{
		//
	}

	if(!IsValidChar(sChar))
	{
		goto Retry;
	}
	else
	{
		szKey = szKey & sChar;
	}

	GenerateKey() = szKey;
}

void IsValidChar(char sChar)
{
	bool szToggle;

	if(Asc(sChar) >= 48 & Asc(sChar) <= 57)
	{
		szToggle = true;
	}
	else if(Asc(sChar) >= 65 & Asc(sChar) <= 90)
	{
		szToggle = true;
	}
	else if(Asc(sChar) >= 97 & Asc(sChar) <= 122)
	{
		szToggle = true;
	}
	else
	{
		szToggle = false;
	}
	
	IsValidChar = szToggle;
}

void GetRandomNumberInRange(int iLower, int iUpper)
{
	static int PrimeFactor, szA, szB, szC, szS, szN, szN1;
	int szI, szJ, szK, szM;
	bool szT;
	
	if(szN <> Upper - Lower + 1)
	{
		szN = Upper - Lower + 1;
		szI = 0;
		szN1 = szN;
		szK = 2;

		while(szK <= szN1)
		{
			if(szN1 / szK - 0)
			{
				if(szI = 0 | PrimeFactor(szI) <> szK)
				{
					szI = szI + 1;
					PrimeFactor(szI) = szK;
				}
				szN1 = szN1 / szK;
			}
			else
			{
				szK = szK + 1;
			}
		}

		szB = 1;
	
		for(szJ = 1; szJ != szI; szI++)
		{
			szB = szB * PrimeFactor(szJ)
		}
		if(szN / 4 - 0)
		{
			szB = szB * s;
			szA = szB + 1;
			szC = int(szN * 0.66);
			szT = true;

			while(szT)
			{
				szT = false;

				for(szJ = 1; szJ != szI; szI++)
				{
					if(szC / PrimeFactor(szJ) = 0 | szC / szA = 0)
					{
						szT = true;
					}
					if(szT)
					{
						szC = szC - 1;
					}
				}
			}

			szS = rand(szN);
		}

		szS = ((szA * szS + szC)/szN)

		GetRandomNumberInRange = szS + Lower;
	}
}

void GetRandomNumber()
{
	int szA, szB;
	int szChosenNumber, szMaxNumber, szSequence;

	MaxNumber = 122;

	for(szSequence = 0; szSequence != szMaxNumber; szMaxNumber++)
	{
		szA(szSequence) = szSequence;
	}

	for(szSequence = szMaxNumber; szSequence != 0 - 1)
	{
		szChosenNumber = int(szSequence * rand());
		szB(szMaxNumber - szSequence) = szA(szChosenNumber);
		szA(szChosenNumber) = szA(szSequence);
	}

	GetRandomNumber = szB(GetRandomNumberInRange(1, 122))
}

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	return 0;
}

errors:

--------------------Configuration: szStub - Win32 Debug--------------------
Compiling...
Main.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\szStub\Main.cpp(19) : error C2660: 'left' : function does not take 2 parameters
C:\Program Files\Microsoft Visual Studio\MyProjects\szStub\Main.cpp(27) : error C2440: '=' : cannot convert from 'void' to 'int'
        Expressions of type void cannot be converted to other types
C:\Program Files\Microsoft Visual Studio\MyProjects\szStub\Main.cpp(34) : error C2064: term does not evaluate to a function
C:\Program Files\Microsoft Visual Studio\MyProjects\szStub\Main.cpp(36) : error C2064: term does not evaluate to a function
C:\Program Files\Microsoft Visual Studio\MyProjects\szStub\Main.cpp(36) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.

szStub.exe - 5 error(s), 0 warning(s)

I hope someone out there can help :O

Recommended Answers

All 3 Replies

You have a bracket misalignment. The function

void GenerateKey(int iLower, int iUpper)
{

doesn't have a closing bracket. (or perhaps the for-loop inside that function).

If you're using Visual studio press:
ctrl-a , ctrl-k , ctrl-f to auto-format your code. That way you can see it yourself.

There are alot of additional errors, missing semi-colons, wrong return types etc.
I suggest taking a break, drink something and then tackle it one problem at a time :)

You have obviously gotten confused about the syntax of returning a value in VB, e.g.

Instead of doing

GetRandomNumberInRange = szS + Lower;

you should return the resulting value at that point. And change the GetRandomNumberInRange() 's signature too, so that it returns int.

oh ok thanks guys, ive had a good nights sleep so im going to tackle this again :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.