Hi! I have a problem when I am trying to set the rules and trying to let the program break out of the loop (only if succesful).
And here's my code:
I've commented everything to help you understand what has happened to me.
Using Visual C++ 6 Service Pack 5
by Grayson Peddie
myfirstapp.cpp Dated: 5/25/02
#include <iostream> // cout and cin definitions
#include <string> // I might think that this file contains getline...?
using namespace std; // For use with std:: namespace
void name_squall(void) // Implemented a name_squall function
char max_squall_char = 13; // max_squall_char has a charactor array of 14
char squall(max_squall_char); // assigned squall to max_squall_char
// for a maximin of 12 charactors
char *psquall; // psquall is a pointer to a type char with
// a maximin of 13 charactors
*psquall = &squall; // psquall is a pointer to squall
do // Start a loop
// Output a text to a screen
cout<<"Enter a name for a charactor:\n\n"
<<"Names should not be longer than 12.\n"
<<"\tDefault: Squall \n\n";
// This is a string with a pointer from squall,
// Next is an array of max_squall_char and the last is escape code
// which drops down to a next line. I enclosed those with "( )".
cin.getline(&squall, max_squall_char, '\n');
// Here's what I have trouble with:
The rules are:
If I entered too many charactors, then I will get an error.
If I entered less than 12, then I may proceed out of a function
but I couldn't get through!
If I don't enter any charactors, then I also get an error.
I'm not talking about compiler errors.
if(*psquall >= &squall && squall++)
cout<<"Error!" << endl << endl
<<"\tCan't enter a name longer than 12 charactors.";
if(*psquall < &squall && squall--)
cout<<"You named a charactor "<<*psquall
// This is where the code comes in when I forgot to enter charactors.
if (" ")
while(*psquall <= &squall); // Yet that loop tells the program to go
// from the beginning, regardless if I
// set the <= or >= operator.
// Well, it could skip the "cin" part...
cout<<"Are you ready to continue? 1 or 2 ";
// ...which didn't work because the program doesn't tell me to enter 1 for
// yes or 2 for no.
And by the way, sorry to make a mess, but VC++ uses IntelliSense Technology by Microsoft. So you just have to go with it so.