Results 1 to 10 of 10
  1. #1
    VvITylerIvV's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    The streets
    Posts
    668
    Reputation
    5
    Thanks
    61
    My Mood
    In Love

    having a problem...

    I tried to clean up my code, made a few functions, a whole new header for variables. And it all worked fine. Until I tried to use the Frestart function from functions.h in TBQ.cpp.

    functions.h
    [php]
    #include <iostream>
    #include <string>
    #include <sstream>

    using namespace std;

    int aaaa;

    void Felse(){
    cout << "that wasn't an answer...\n";
    }

    void test (string a, char c[40], char e[40] ){
    if(a == "y"){
    cout << c << endl;
    }
    else if(a == "n"){
    cout << e << endl;
    }
    else { Felse(); }
    }

    void Frestart (string ITSASTRING, string restart){
    cout <<"time to end this game... if you want "<<endl;

    cout << "would you like to play again? (y/n)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> restart;

    if (restart == "y"){ // if they want to restart, play again
    cout << "alright, here we go!!!!"<<endl;
    }
    else if (restart == "n"){ // if they don't ensure they don't
    cout << "I'm going to ask again, just for safety's sake. Would you like to play again? (y/n)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> restart;

    if (restart == "y"){
    cout << "alright, I'm going to restart it for you"<<endl;
    }
    else if (restart == "n"){
    exit(0);
    }
    else {
    cout << "sorry, what was that?\ndid you want to replay or not? (y/n)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> restart;

    if (restart == "y"){
    cout << "alright, going to restart it for you"<<endl;
    }
    else{
    exit(0);
    }
    }
    }
    }
    [/php]

    variables.h
    [php]
    #include "functions.h"
    int thisIsANumber; // used for random number
    string yesOrNo; // used for favourite number
    string likeShitTacos; // used for waffles
    string BelgianOrEggos; // used for belgian or eggos
    string strawberry; // used for strawberries and whipped cream on belgian waffles
    string syrup; // used for syrup on belgian waffles
    string ITSASTRING; // empty string, used for transfering variables
    string firstname; // second string, used for first name
    string lastname; // third string, used for last name
    int age; // int, used for age
    string randomword; // used for random word
    int favouritenumber; // used for favourite number
    string girlsorboys; // likes girls or boys
    string boyorgirl; // is a boy or girl
    string tylerishot; // am I hot? obviously...
    string girlright; // your a girl right?
    string justinbieber; // you better not like justin bieber
    string pancakes; // like pancakes?
    string likewinter; // like winter?
    string kissedcody; // ever kissed cody miller?
    string Cgirl; // girl kissed cody right?
    string favseason; // fav season
    string restart; // restart game?
    string areyousure; // sure you don't wanna restart?
    string AREyousure; // absolutely sure you wanna quit?
    string computer; // like the computer
    string boyORgirlfriend; // have a boyorgirlfriend
    string girlORboyfriend; // boy or girlfriend?
    string boyfriendname; // boyfriend's name
    string girlfriendname; // girlfriend's name
    string picklesandpopcorn; // like pickles and popcorn?
    string eathair; // eat your hair?
    string smoothies; // like smoothies?
    string hotdogs; // like hotdogs?
    string princesses; // like princesses?
    [/php]

    tbq.cpp
    [php]
    #include "functions.h"
    #include "variables.h"

    using namespace std;
    int main()
    {
    do {
    system("cls");
    cout << "Hi, what is your FIRST name?" << endl;
    getline (cin,ITSASTRING); // getting the input from this line and inputting it into ITSASTRING
    stringstream(ITSASTRING) >> firstname; // transferring data from ITSASTRING to firstname
    cout << "Alright " << firstname << " what is your last?";
    getline (cin,ITSASTRING); // getting the input from this line and inputting it into ITSASTRING
    stringstream(ITSASTRING) >> lastname; // transferring data from ITSASTRING to lastname

    cout << "alrighty then " << firstname<<" " <<lastname <<", how old are you?" << endl; // displaying firstname lastname and asking how old
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> age;// the usual cin >> age
    if (age < 20) { // if age is less than 20 do the following
    cout << "Hi " << firstname<< " " <<lastname << ", welcome to my application!\ntype some random word!"<< endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> randomword;
    }
    else
    {// age was more than 20 so we do the following
    cout << "Hi " << firstname<<" " <<lastname <<" sorry, but you are too old." << endl;
    exit(0);
    }

    cout << "thats the first word that came to your mind? weird...\n"<< endl;
    cout << "Enter a number"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> thisIsANumber;

    cout << "was this your favourite number?"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> yesOrNo;

    if(yesOrNo == "y")
    {
    cout << "oh, well that was an interesting favourite number.\n"<<endl;
    }
    else if(yesOrNo == "n")
    {
    cout << "oh... what is your favourite number?\n"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> favouritenumber;
    }
    else
    {
    cout << "that wasn't an answer, genius"<<endl;
    }
    cout << "Do you like waffles?!?!?!!? (y/n)\n"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> likeShitTacos;
    if(likeShitTacos == "y")
    {
    cout << "I knoww they are awesome!!!! Belgian or Eggos?\n"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> BelgianOrEggos;
    if(BelgianOrEggos == "b")
    {
    cout << "yeaaah those are the best... with strawberrys and whipped cream right?(y/n)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> strawberry;
    if(strawberry == "y")
    {
    cout << "mmmm waffles with strawberries and whipped cream... mmmmmmmm"<<endl;
    }

    else if(strawberry == "n")
    {
    cout << "ewwwww... You still use syrup though right? (y/n)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> syrup;
    if(syrup == "y")
    {
    cout << "good... I was worried"<<endl;
    }
    else if(syrup == "n")
    {
    cout << "WTF MAN!!! PLAIN WAFFLES?!?!?! YOUR CRAZY"<<endl;
    }
    else
    {
    cout << "one more answer and thats it... Your booted off of this I swear."<<endl;
    }
    }
    else
    {
    cout << "STOP ANSWERING THAT!!!!!!!!!!!!!"<<endl;
    }

    }
    else if(BelgianOrEggos == "e")
    {
    cout << "reaally? Eggos more then Belgians? You've clearly never had a belgian waffle before..."<<endl;
    }
    else
    {
    cout << "that wasn't an answer, stop saying random letters... it makes me confused"<<endl;
    }
    }
    else if(likeShitTacos == "n")
    {
    cout << "Whatt?!?! you don't like waffles? gtfo...\n"<<endl;
    }
    else
    {
    cout << "This wasn't a choice, gtfo\n"<<endl;
    }
    cout << "do you like girls or boys? (g/b)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> girlsorboys;

    if (girlsorboys == "g")
    {
    cout << "Oh, great, I do as well. You are a boy or a girl? (b/g)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> boyorgirl;
    if (boyorgirl == "g"){
    cout << "oh..."<<endl;
    }
    else if (boyorgirl == "b"){
    cout << "oooohhh good "<<endl;
    }
    else{
    cout << "don't push the wrong buttons please!! you're going to drive me insane!!!!"<<endl;
    }
    }
    else if (girlsorboys == "b")
    {
    cout << "ewwwww are you a boy or a girl... (b/g)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> boyorgirl;
    if (boyorgirl == "b"){
    cout << "ok then......\n";
    }
    else if (boyorgirl == "g"){
    cout << "ok, good "<<endl;
    }
    else{
    cout << "really... stop with the insane clicking of these random buttons"<<endl;

    }
    }

    cout << "Do you think tyler is hooooot??? (y/n)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> tylerishot;

    if (tylerishot == "y"){
    cout << "alrighty then... your a girl right? (y/n)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> girlright;

    if (girlright == "y"){
    cout << "we should like, totally go out sometime!! "<<endl;
    }
    else if (girlright == "n"){
    cout << "umm... ok then... awkwardddd"<<endl;
    }
    else{
    cout << "don't. push. the. wrong. button. again.!!!!!"<<endl;
    }
    }

    else if (tylerishot == "n"){
    cout <<"WHATT?!?! IM ABSOLUTELY 100% HOOTTT. get a life kid"<< endl;
    }
    else{
    cout <<"STOP HITTING THAT BUTTON, JESUS CHRIST."<<endl;
    }
    cout << "Do you like justin bieber? (y/n)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> justinbieber;
    if (justinbieber == "y"){
    exit(0);
    }
    else if (justinbieber == "n"){
    cout << "FINALY, SOMEBODY WHO'S HUMAN!"<<endl;
    }
    else{
    cout << "WTF?! DO YOU LIKE HIM OR NOT... (y/n)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> justinbieber;
    if (justinbieber == "y"){
    cout <<"get a life..."<<endl;
    system ("pause");
    exit(0);
    }
    else if (justinbieber == "n"){
    cout << "THANK GOD!!!!"<<endl;
    }
    else{
    cout << "really? again? your getting booted."<<endl;
    system ("pause");
    exit(0);
    }

    }
    cout << "do you like pancakes??? (y/n)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> pancakes;
    if (pancakes == "y"){
    cout <<"awesome you rock!"<<endl;
    }
    else if (pancakes == "n"){
    cout << "you don't like pancakes??? where are you from? the moon?"<<endl;
    }
    else {
    cout << "Can you please not hit the wrong button next time? It's quite annoying you know..."<<endl;
    }
    cout << "Do you like winter? (y/n)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> likewinter;
    if (likewinter == "y"){
    cout << "OEMGEE I ABSOLUTELY LOVE WINTER, WE HAVE SO MUCH IN COMMON )"<<endl;
    }
    else if (likewinter == "n") {
    cout << "ewww... what do you like?\n(s) Summer\n(S) Spring\n(f) Fall" <<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> favseason;
    if (favseason == "s"){
    cout << "really, summer is your favourite... interesting. I hate that season "<<endl;
    }
    else if (favseason == "S") {
    cout << "yeah, springs a pretty good season as well I guess..."<<endl;
    }
    else if (favseason == "f") {
    cout << "Fall, thats an Ok season I guess... Playing in the leaves is pretty fun I guess."<<endl;
    }
    else{
    cout << "Ok... DON'T PUSH THE WRONG BUTTON. I'm seriously going to exit(0); you...."<<endl;
    }
    }
    else {
    cout <<"STOP THAT"<<endl;
    }
    cout <<"Have you ever kissed Cody Miller? (y/n)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> kissedcody;
    if (kissedcody == "y"){
    cout <<"Please tell me your a girl...(y/n)"<<endl;
    getline (cin,ITSASTRING);
    stringstream(ITSASTRING) >> Cgirl;
    if (Cgirl == "y"){
    cout <<"oh... how interesting, I didn't know he's kissed YOU."<<endl;
    }
    else if (Cgirl == "n"){
    cout << "oh... I'll be talking to him later"<<endl;
    }
    else {
    cout << "are you going to stop hitting the wrong button any time soon?"<<endl;
    }
    }
    else if (kissedcody == "n"){
    cout <<"Well, I could've figured THAT out..."<<endl;
    }
    else{
    cout<<"FOR **** SAKES STOP THAT..."<<endl;
    }
    Frestart (ITSASTRING, restart);
    }

    while(restart == "y");
    return 0;
    }
    [/php]

    when it gets to Frestart(ITSASTRING, restart); it does all the code in the function Frestart then closes the program... I want it to do all the code in the function then continue with the program (do while loop)

    I gotta go to sleep now, if you wanna help then just run this in your compiler and you'll see what my problem is
    Favourite quotes:

    Code:
    I don't need easy, I just need possible. ~ Me 
    
    There are three birds on a fence. Two decide to fly away, how many are left? Three, just because you decide to do something doesn't mean you've done it. ~ Don't know who said this
    
    Do not go where the path may lead, go instead where there is no path and leave a trail. ~ Ralph Waldo Emerson
    Quote Originally Posted by VirtualSia View Post
    You both have a very weird and awkward view on Computer science.
    Computer science is about computing, which is programming.
    Definition of computing: The use or operation of computers.
    Turning on my computer = computing = programming
    LAWLFAIL

  2. #2
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Would look. But there are 2 things preventing me.
    1. Too long
    2. You using dat [php]getline(cin,ITSASTRING);[/php] again

  3. #3
    C4P's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    34
    Reputation
    10
    Thanks
    2
    My Mood
    Happy
    your problem is at the FRestart function.
    you can't send a parameter like that if you want it to be changed inside the function.
    try to use the & operator before the string parameter
    like this:
    void Frestart (){

    by the way, are you trying to make this project as possible?
    just change the function to return a string and return the string from the input. much easier.

  4. #4
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Lol. Do you build each project over another? Still some of my variables i see

  5. #5
    VvITylerIvV's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    The streets
    Posts
    668
    Reputation
    5
    Thanks
    61
    My Mood
    In Love
    Quote Originally Posted by Koreans View Post
    Lol. Do you build each project over another? Still some of my variables i see
    No, I just don't re-write all the code.
    Favourite quotes:

    Code:
    I don't need easy, I just need possible. ~ Me 
    
    There are three birds on a fence. Two decide to fly away, how many are left? Three, just because you decide to do something doesn't mean you've done it. ~ Don't know who said this
    
    Do not go where the path may lead, go instead where there is no path and leave a trail. ~ Ralph Waldo Emerson
    Quote Originally Posted by VirtualSia View Post
    You both have a very weird and awkward view on Computer science.
    Computer science is about computing, which is programming.
    Definition of computing: The use or operation of computers.
    Turning on my computer = computing = programming
    LAWLFAIL

  6. #6
    C4P's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    34
    Reputation
    10
    Thanks
    2
    My Mood
    Happy
    my bad, forgot it:
    like that
    void Frestart (string ITSASTRING, string &restart){

  7. #7
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    PS. In a production environment, strings are too inefficient in terms of operation speed and memory use. Consider using integers, booleans and other data types that occupy less memory.

    PS2. string Var1, Var2, Var3 works as well.

  8. #8
    VvITylerIvV's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    The streets
    Posts
    668
    Reputation
    5
    Thanks
    61
    My Mood
    In Love
    Quote Originally Posted by freedompeace View Post
    PS. In a production environment, strings are too inefficient in terms of operation speed and memory use. Consider using integers, booleans and other data types that occupy less memory.

    PS2. string Var1, Var2, Var3 works as well.
    Yes, I understand that. But its my personal preference. I have been using chars, but I want to use strings for yes/no answers rather then y/n. I am going to be getting around to that as soon as I can but I have some more important things to do first.
    Favourite quotes:

    Code:
    I don't need easy, I just need possible. ~ Me 
    
    There are three birds on a fence. Two decide to fly away, how many are left? Three, just because you decide to do something doesn't mean you've done it. ~ Don't know who said this
    
    Do not go where the path may lead, go instead where there is no path and leave a trail. ~ Ralph Waldo Emerson
    Quote Originally Posted by VirtualSia View Post
    You both have a very weird and awkward view on Computer science.
    Computer science is about computing, which is programming.
    Definition of computing: The use or operation of computers.
    Turning on my computer = computing = programming
    LAWLFAIL

  9. #9
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love
    Quote Originally Posted by VvITylerIvV View Post
    Yes, I understand that. But its my personal preference. I have been using chars, but I want to use strings for yes/no answers rather then y/n. I am going to be getting around to that as soon as I can but I have some more important things to do first.
    But what happens if somebody thinks its y/n and then it skips around?

    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  10. #10
    VvITylerIvV's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    The streets
    Posts
    668
    Reputation
    5
    Thanks
    61
    My Mood
    In Love
    Quote Originally Posted by Kallisti View Post


    But what happens if somebody thinks its y/n and then it skips around?
    It's going to be

    If(a == "y" || "ye" || "yes"){}

    and I'll use something to change all the text to lowercase... I saw that somewhere.
    Favourite quotes:

    Code:
    I don't need easy, I just need possible. ~ Me 
    
    There are three birds on a fence. Two decide to fly away, how many are left? Three, just because you decide to do something doesn't mean you've done it. ~ Don't know who said this
    
    Do not go where the path may lead, go instead where there is no path and leave a trail. ~ Ralph Waldo Emerson
    Quote Originally Posted by VirtualSia View Post
    You both have a very weird and awkward view on Computer science.
    Computer science is about computing, which is programming.
    Definition of computing: The use or operation of computers.
    Turning on my computer = computing = programming
    LAWLFAIL

Similar Threads

  1. Okay so I have a problem
    By appletart in forum Combat Arms Hacks & Cheats
    Replies: 5
    Last Post: 08-16-2008, 01:55 PM
  2. Have a problem with my Korean Warrock Acc
    By Kevin.B in forum WarRock Korea Hacks
    Replies: 2
    Last Post: 08-09-2008, 02:26 PM
  3. hi i have a problem
    By priit1 in forum WarRock - International Hacks
    Replies: 2
    Last Post: 12-20-2007, 11:36 AM
  4. i have a problem
    By priit1 in forum WarRock - International Hacks
    Replies: 5
    Last Post: 09-27-2007, 12:16 PM
  5. i have a problem
    By mpghhackersrock123 in forum WarRock - International Hacks
    Replies: 15
    Last Post: 09-26-2007, 07:28 AM