Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ halp =/

Name: Anonymous 2007-06-12 10:52 ID:NALSuzi+

HAI
I'm learning some C++ and last night wrote this:

#include <iostream>
using namespace std;

int main()
{
    char gender[30];
    char fname[50];
    char sname[50];
    char hate[30];
    char wep[30];
    char hobby[50];
   
    cout<<"Please do not use spaces in your answer, it will mess up the program due to bad writing =/ "<<endl;
    cout<<endl;
    /* Yes I'm rubbish ok? */
    cout<<"Please enter either he/she, according to your gender: ";
    cin>> gender;
    cin.ignore();
    cout<<"And what is your first name?: ";
    cin>> fname;
    cout<<"Well hello there, "<< fname <<"! What is your surname?: ";
    cin>> sname;
    cin.ignore();
    cout<<"Thanks. So far you have told me that you are a "<< gender <<", and your name is "<< fname <<" "<< sname <<"."<<endl;
    cout<<endl;
    cout<<"What is the one thing you hate most?: ";
    cin>> hate;
    cin.ignore();
    cout<<"What is your weapon of choice?: ";
    cin>> wep;
    cin.ignore();
    cout<<"What is your favourite hobby/pastime?: ";
    cin>> hobby;
    cin.ignore();
    cout<<endl;
    cout<<"Ok, let's begin our story..."<<endl;
    cout<<endl;
    cout<<endl;
    cout<<""<< fname <<" "<< sname <<" thought "<< gender <<"'d take a break from "<< hobby <<"."<<endl;
    cout<<""<< gender <<" decided to rid the world of all traces of "<< hate <<", once and for all."<<endl;
    cout<<"So, brandishing a "<< wep <<", "<< gender <<" set off to seek out and destroy "<< hate <<"..."<<endl;
    cout<<"But "<< gender <<" died on the mission and "<< hate <<" remained forever more."<<endl;
    cout<<"Poor "<< fname <<", "<< gender <<" should have stuck with "<< hobby <<"."<<endl;
    cin.get();
   
    return 0;
}

As you can see, I'm a total n00b with only a basic knowledge of int, float and char. I was wondering which type i could use so that you choose one of 2 options, and most importantly, how I could allow spaces to be used in input without messing up how the program remembers it. Tried google but failed.

Name: Anonymous 2007-06-12 13:29 ID:Heaven

>>24
I'll go and register on some c++ forum or other

I think that is a good idea in your case. You're greatly hurting your programming, and if you really want to do that, doing it with other people living the same mistake will probably be a lot less painful.

no offence guys but all this saging, and general trying to put me off is starting to get to me.

Saging is not an insult. People telling you to ditch C++ are seriously trying to help you. I made the mistake of blindly using C++ against all odds for over five years, and would not want anyone to repeat it, but I think no one will speak sense into your mind.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List