Follow us on Twitter!
The measure of a mans life is not how well he dies, but how well he lives.
Wednesday, April 16, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 21
Guests Online: 15
Members Online: 6

Registered Members: 82813
Newest Member: VesuviusSentinel
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

C++ Problem


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 17-09-08 20:11
I have created a small program, just to get a feel for C++, but every time that I run it keeps printing the first line of the program until stopped with
Ctrl + C. Does any one have any solutions as to why. Thanks.


Author

RE: C++ Problem

fuser
Member



Posts: 960
Location: in front of a computer (duh)
Joined: 05.04.07
Rank:
Mad User
Posted on 17-09-08 20:16
wow, I need to be psychic just to help you is it?


img.userbarz.com/51/10006.png
img.userbarz.com/146/29144.gif
img.userbarz.com/99/19602.jpg
img.userbarz.com/4/600.png
img.userbarz.com/45/8814.gif
img360.imageshack.us/img360/9231/bfbarlr0.jpg
[url=http://userbarz.com/][img]ht
catinthecpu@hotmail.com
Author

RE: C++ Problem


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 17-09-08 20:17
You should post your code.


Author

RE: My C++ Program


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 17-09-08 20:20
#include <cstdlib>
#include <iostream>

using namespace std;

int main(void)
{
;int iPassword;
;int iPassword2;
;int iPassword3;
while(true)
(

cout << "Please enter the password: " ) << endl;
cin >> iPassword
;if(iPassword = 255)
(
cout << "That is correct." << endl);


if (iPassword < 255 | iPassword > 255)
(
cout << "That is incorrect, please try again." << endl);
cout << "Please enter the second password: " << endl;
cin >> iPassword2
;if(iPassword2 = 916)
(
cout << "That is correct."Wink << endl;
if (iPassword2 < 916 | iPassword2 > 916)
(
cout << "That is incorrect, please try again." << endl << endl);
;if(iPassword3 = 5131)
(
cout << "ACCESS GRANTED" << endl << endl);
if (iPassword3 < 5131 | iPassword3 > 5131)
(
cout << "That is incorrect, please try again." << endl << endl);
system("PAUSE"Wink;
return 0;
}


Author

RE: C++ Problem


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 17-09-08 20:27
Correct me if I'm wrong but it looks like there's a lot of mistakes in this program.




Edited by on 17-09-08 20:37
Author

RE: C++ Problem

yours31f
Member



Posts: 1678
Location: Dallas Texas
Joined: 27.04.07
Rank:
Elite
Posted on 17-09-08 20:36
Yes, At a glance I found four.
Code

#include <cstdlib>
#include <iostream>

using namespace std;

int main(void)
{
    int iPassword;  // also just noticed that you had ; at the beginning, don't put then there.
    int iPassword2;
    int iPassword3;
    while(true)
    (
               
    cout << "Please enter the password: "  << endl; // the parentheses
    cin >> iPassword;
if(iPassword == 255) 
  // you had to set this as == not = or it will set it as  255
    (
                  cout << "That is correct." << endl);

                 
    if (iPassword < 255 | iPassword > 255)
    (
                  cout << "That is incorrect, please try again." << endl);
    cout << "Please enter the second password: " << endl;
    cin >> iPassword2;
if(iPassword2 == 916) //same here
    (
                   cout << "That is correct.") << endl;
    if (iPassword2 < 916 | iPassword2 > 916)
    (
                   cout << "That is incorrect, please try again." << endl << endl);
    if(iPassword3 == 5131) // and here and an extra ; at the begining
    (
                   cout << "ACCESS GRANTED" << endl << endl);
    if (iPassword3 < 5131 | iPassword3 > 5131)
    (
                   cout << "That is incorrect, please try again." << endl << endl);
    system("PAUSE");
    return 0;
}





Debugging is what programmers do to beta software to make it take up more room on your hard drive if it is running too efficiently.


img259.imageshack.us/img259/3713/sigr.png



Edited by yours31f on 17-09-08 21:34
yours31f@live.com yours31f@yahoo.com rpwd.info
Author

RE: C++ Problem


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 17-09-08 21:25
skathgh420 wrote:
Correct me if I'm wrong but it looks like there's a lot of mistakes in this program.

Indeed there are, I couldn't quite get my head around it all.
SpeedyJ250, if you're just getting the feel of C++ I'd suggest you'd start off by doing something simpler just to get the hang of the individual functions you're trying to use.
Also what yours31f said about using two = signs when comparing, same goes for most other things as well, such as |, which could in your attempt be easily replaced with an "else" statement.


Author

RE: C++ Problem


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 17-09-08 21:29
Also you can surely use more efficient coding practices, like if else statments. Pseudocode:

if password = 619:
print "That is correct"
else:
print "That is incorrect"


Author

RE: C++ Problem

yours31f
Member



Posts: 1678
Location: Dallas Texas
Joined: 27.04.07
Rank:
Elite
Posted on 17-09-08 22:05
I also added that you don't need to put semicolons in the beginning of a command.


Debugging is what programmers do to beta software to make it take up more room on your hard drive if it is running too efficiently.


img259.imageshack.us/img259/3713/sigr.png

yours31f@live.com yours31f@yahoo.com rpwd.info