Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Winapi//gui C++ Question
New Posts  All Forums:Forum Nav:

Winapi//gui C++ Question

post #1 of 18
Thread Starter 
Hey, guys, I am new and this is my first compiled program. I am having a little issue.

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main ()
{
cout << " \
\
Welcome to LyokoHaCk's carthage emulator. I do not own Code:Lyoko and am not currently affiliated with MoonScoop. \
\
";
string SCIPIO;
string mystr;
cout << "Enter your name here: ";
getline (cin, mystr);
cout << "Please enter the password " << mystr << ":";
getline (cin, SCIPIO);

cout << "Welcome to Carthage " << mystr << "!\
";

What can I put in here so if I put in a wrong answer, it will say INCORRECT code until i put in the right one (which is scipio)?
post #2 of 18
Maybe

Code:
if (Userinput == SCIPIO)
{
     cout << "Correct";
}

else
     cout << "Incorrect";
I <3 480's
(13 items)
 
  
CPUMotherboardGraphicsRAM
E8600 ASUS P5Q PRO Turbo Evga GTX 480 4GB OCZ Platinum 
Hard DriveOSMonitorPower
x2 30GB Vertex SSD in RAID0, 120GB WD Windows 7 Ultimate 64 bit 19" Dell LCD Corsair TX750 
Case
Cheap Rosewill 
  hide details  
Reply
I <3 480's
(13 items)
 
  
CPUMotherboardGraphicsRAM
E8600 ASUS P5Q PRO Turbo Evga GTX 480 4GB OCZ Platinum 
Hard DriveOSMonitorPower
x2 30GB Vertex SSD in RAID0, 120GB WD Windows 7 Ultimate 64 bit 19" Dell LCD Corsair TX750 
Case
Cheap Rosewill 
  hide details  
Reply
post #3 of 18
Thread Starter 
Is there some type of string I'm supposed to but before this at the beggining of the code like "string scipio;" (Just an example because Dev CPP says its undeclared)
post #4 of 18
No just put quotes around SCIPIO.
I <3 480's
(13 items)
 
  
CPUMotherboardGraphicsRAM
E8600 ASUS P5Q PRO Turbo Evga GTX 480 4GB OCZ Platinum 
Hard DriveOSMonitorPower
x2 30GB Vertex SSD in RAID0, 120GB WD Windows 7 Ultimate 64 bit 19" Dell LCD Corsair TX750 
Case
Cheap Rosewill 
  hide details  
Reply
I <3 480's
(13 items)
 
  
CPUMotherboardGraphicsRAM
E8600 ASUS P5Q PRO Turbo Evga GTX 480 4GB OCZ Platinum 
Hard DriveOSMonitorPower
x2 30GB Vertex SSD in RAID0, 120GB WD Windows 7 Ultimate 64 bit 19" Dell LCD Corsair TX750 
Case
Cheap Rosewill 
  hide details  
Reply
post #5 of 18
Thread Starter 
'Userinput' undeclared (first use this function )
post #6 of 18
Try this:

Code:
if (SCIPIO == "SCIPIO")
{
     cout << "Correct";
}

else
     cout << "Incorrect";
I <3 480's
(13 items)
 
  
CPUMotherboardGraphicsRAM
E8600 ASUS P5Q PRO Turbo Evga GTX 480 4GB OCZ Platinum 
Hard DriveOSMonitorPower
x2 30GB Vertex SSD in RAID0, 120GB WD Windows 7 Ultimate 64 bit 19" Dell LCD Corsair TX750 
Case
Cheap Rosewill 
  hide details  
Reply
I <3 480's
(13 items)
 
  
CPUMotherboardGraphicsRAM
E8600 ASUS P5Q PRO Turbo Evga GTX 480 4GB OCZ Platinum 
Hard DriveOSMonitorPower
x2 30GB Vertex SSD in RAID0, 120GB WD Windows 7 Ultimate 64 bit 19" Dell LCD Corsair TX750 
Case
Cheap Rosewill 
  hide details  
Reply
post #7 of 18
Thread Starter 
No dice. I put in something different and it still advances to the rest of code.
It says incorrect, but I still advance.
post #8 of 18
Code:
#include <iostream>
#include <string>
#include <sstream>
#include <stdio.h>
using namespace std;

int main ()
{
cout << " \
 \
 Welcome to LyokoHaCk's carthage emulator. I do not own Code:Lyoko and am not currently affiliated with MoonScoop. \
 \
";
string SCIPIO;
string mystr;
cout << "Enter your name here: ";
getline (cin, mystr);
Incorrect:
cout << "Please enter the password " << mystr << ":";
getline (cin, SCIPIO);

if (SCIPIO != "SCIPIO")
{
cout << "Incorrect Password. \
";
GOTO Incorrect;
}

else

cout << "Welcome to Carthage " << mystr << "!\
";
}
That should work.

EDIT: You will a do loop for this to work.

EDIT2: I changed the code so it should work now.
I <3 480's
(13 items)
 
  
CPUMotherboardGraphicsRAM
E8600 ASUS P5Q PRO Turbo Evga GTX 480 4GB OCZ Platinum 
Hard DriveOSMonitorPower
x2 30GB Vertex SSD in RAID0, 120GB WD Windows 7 Ultimate 64 bit 19" Dell LCD Corsair TX750 
Case
Cheap Rosewill 
  hide details  
Reply
I <3 480's
(13 items)
 
  
CPUMotherboardGraphicsRAM
E8600 ASUS P5Q PRO Turbo Evga GTX 480 4GB OCZ Platinum 
Hard DriveOSMonitorPower
x2 30GB Vertex SSD in RAID0, 120GB WD Windows 7 Ultimate 64 bit 19" Dell LCD Corsair TX750 
Case
Cheap Rosewill 
  hide details  
Reply
post #9 of 18
Thread Starter 
Sorry, I was out of house. It says 'goto' is undeclared.

or before token and unqualified id... two of like 8 errors
post #10 of 18
Thread Starter 
Never mind, endl; was missing. Thanks man! *Reps*

NOW I AM TRYING SOMETHING ELSE :O PLEASE READ BELOW!
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Winapi//gui C++ Question