•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 391,609 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,607 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 141 | Replies: 3
![]() |
•
•
Join Date: May 2008
Posts: 63
Reputation:
Rep Power: 0
Solved Threads: 1
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
errors:
I hope someone out there can help :O
c++ Syntax (Toggle Plain Text)
#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
•
•
Join Date: Oct 2006
Location: the Netherlands
Posts: 1,562
Reputation:
Rep Power: 8
Solved Threads: 158
You have a bracket misalignment. The function
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
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
Last edited by niek_e : Jul 8th, 2008 at 7:25 am.
do NOT pm me for help, it makes me angry. You wouldn't like me when I'm angry...
•
•
Join Date: Nov 2007
Posts: 829
Reputation:
Rep Power: 4
Solved Threads: 168
You have obviously gotten confused about the syntax of returning a value in VB, e.g.
Instead of doing
you should return the resulting value at that point. And change the
Instead of doing
GetRandomNumberInRange = szS + Lower;
GetRandomNumberInRange() 's signature too, so that it returns int. ![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
- Simple Programming Errors (Computer Science and Software Design)
- confused with errors in c++ (C++)
- Windows XP and Corel Suite 8 (WP8) errors (Windows NT / 2000 / XP / 2003)
- Loader.EXE and IEDLL.EXE errors (Web Browsers)
- Errors during scandisk (Windows 9x / Me)
- Upgrading Xp Home to Pro - ERRORS! (Windows NT / 2000 / XP / 2003)
- strange annoying errors (Windows NT / 2000 / XP / 2003)
- w2k server errors (Windows NT / 2000 / XP / 2003)
- Two Problems- "Page Cannot Be Displayed" Errors, Z (Windows NT / 2000 / XP / 2003)
Other Threads in the C++ Forum
- Previous Thread: stingstream and assigning fields of csv files to variables
- Next Thread: Get String^ From Another Forms textBox1



Linear Mode