User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: May 2008
Posts: 63
Reputation: FTProtocol is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
FTProtocol FTProtocol is offline Offline
Junior Poster in Training

Just a few errors :(

  #1  
Jul 8th, 2008
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

  1. #include <windows.h>
  2. #include <iostream>
  3.  
  4. #pragma comment(linker,"/FILEALIGN:0x200 /MERGE:.data=.text /MERGE:.rdata=.text /SECTION:.text,EWR /IGNORE:4078")
  5.  
  6. void IsValidChar(char sChar);
  7. void GetRandomNumberInRange(int iLower, int iUpper);
  8. void GetRandomNumber();
  9.  
  10. char exeData, DecString, CurrentCHAR, CHARCrypted;
  11. char FinalSTR, Spliting, szStr, szStr2, szStr3;
  12. bool CryptER;
  13.  
  14. void TempPath()
  15. {
  16. char WindirS[255], TEMP;
  17.  
  18. TEMP = GetTempPath(255, WindirS);
  19. TempPath = std::left(WindirS, TEMP);
  20. }
  21.  
  22. void GenerateKey(int iLower, int iUpper)
  23. {
  24. char szKey, szChar, Chr, sChar;
  25. int iLen, iLoop;
  26.  
  27. iLen = GetRandomNumberInRange(iLower, iUpper);
  28.  
  29. for(iLoop = 1; iLoop != iLen; iLen++)
  30. {
  31.  
  32. Retry:
  33.  
  34. sChar = Chr(GetRandomNumber());
  35.  
  36. while(sChar = Chr(34))
  37. {
  38. //
  39. }
  40.  
  41. if(!IsValidChar(sChar))
  42. {
  43. goto Retry;
  44. }
  45. else
  46. {
  47. szKey = szKey & sChar;
  48. }
  49.  
  50. GenerateKey() = szKey;
  51. }
  52.  
  53. void IsValidChar(char sChar)
  54. {
  55. bool szToggle;
  56.  
  57. if(Asc(sChar) >= 48 & Asc(sChar) <= 57)
  58. {
  59. szToggle = true;
  60. }
  61. else if(Asc(sChar) >= 65 & Asc(sChar) <= 90)
  62. {
  63. szToggle = true;
  64. }
  65. else if(Asc(sChar) >= 97 & Asc(sChar) <= 122)
  66. {
  67. szToggle = true;
  68. }
  69. else
  70. {
  71. szToggle = false;
  72. }
  73.  
  74. IsValidChar = szToggle;
  75. }
  76.  
  77. void GetRandomNumberInRange(int iLower, int iUpper)
  78. {
  79. static int PrimeFactor, szA, szB, szC, szS, szN, szN1;
  80. int szI, szJ, szK, szM;
  81. bool szT;
  82.  
  83. if(szN <> Upper - Lower + 1)
  84. {
  85. szN = Upper - Lower + 1;
  86. szI = 0;
  87. szN1 = szN;
  88. szK = 2;
  89.  
  90. while(szK <= szN1)
  91. {
  92. if(szN1 / szK - 0)
  93. {
  94. if(szI = 0 | PrimeFactor(szI) <> szK)
  95. {
  96. szI = szI + 1;
  97. PrimeFactor(szI) = szK;
  98. }
  99. szN1 = szN1 / szK;
  100. }
  101. else
  102. {
  103. szK = szK + 1;
  104. }
  105. }
  106.  
  107. szB = 1;
  108.  
  109. for(szJ = 1; szJ != szI; szI++)
  110. {
  111. szB = szB * PrimeFactor(szJ)
  112. }
  113. if(szN / 4 - 0)
  114. {
  115. szB = szB * s;
  116. szA = szB + 1;
  117. szC = int(szN * 0.66);
  118. szT = true;
  119.  
  120. while(szT)
  121. {
  122. szT = false;
  123.  
  124. for(szJ = 1; szJ != szI; szI++)
  125. {
  126. if(szC / PrimeFactor(szJ) = 0 | szC / szA = 0)
  127. {
  128. szT = true;
  129. }
  130. if(szT)
  131. {
  132. szC = szC - 1;
  133. }
  134. }
  135. }
  136.  
  137. szS = rand(szN);
  138. }
  139.  
  140. szS = ((szA * szS + szC)/szN)
  141.  
  142. GetRandomNumberInRange = szS + Lower;
  143. }
  144. }
  145.  
  146. void GetRandomNumber()
  147. {
  148. int szA, szB;
  149. int szChosenNumber, szMaxNumber, szSequence;
  150.  
  151. MaxNumber = 122;
  152.  
  153. for(szSequence = 0; szSequence != szMaxNumber; szMaxNumber++)
  154. {
  155. szA(szSequence) = szSequence;
  156. }
  157.  
  158. for(szSequence = szMaxNumber; szSequence != 0 - 1)
  159. {
  160. szChosenNumber = int(szSequence * rand());
  161. szB(szMaxNumber - szSequence) = szA(szChosenNumber);
  162. szA(szChosenNumber) = szA(szSequence);
  163. }
  164.  
  165. GetRandomNumber = szB(GetRandomNumberInRange(1, 122))
  166. }
  167.  
  168. int APIENTRY WinMain(HINSTANCE hInstance,
  169. HINSTANCE hPrevInstance,
  170. LPSTR lpCmdLine,
  171. int nCmdShow)
  172. {
  173. return 0;
  174. }

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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: the Netherlands
Posts: 1,562
Reputation: niek_e is a jewel in the rough niek_e is a jewel in the rough niek_e is a jewel in the rough niek_e is a jewel in the rough 
Rep Power: 8
Solved Threads: 158
niek_e's Avatar
niek_e niek_e is offline Offline
Posting Virtuoso

Re: Just a few errors :(

  #2  
Jul 8th, 2008
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
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...
Reply With Quote  
Join Date: Nov 2007
Posts: 829
Reputation: mitrmkar is a jewel in the rough mitrmkar is a jewel in the rough mitrmkar is a jewel in the rough 
Rep Power: 4
Solved Threads: 168
mitrmkar mitrmkar is offline Offline
Practically a Posting Shark

Re: Just a few errors :(

  #3  
Jul 8th, 2008
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.
Reply With Quote  
Join Date: May 2008
Posts: 63
Reputation: FTProtocol is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
FTProtocol FTProtocol is offline Offline
Junior Poster in Training

Re: Just a few errors :(

  #4  
Jul 8th, 2008
oh ok thanks guys, ive had a good nights sleep so im going to tackle this again
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 12:13 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC