If you're so new that nested loops throw you for a loss, I'd hold off on Stroustroup's book for a while. Deitel & Deitel is a popular textbook.
Type: Posts; User: Brown Drake
If you're so new that nested loops throw you for a loss, I'd hold off on Stroustroup's book for a while. Deitel & Deitel is a popular textbook.
What you want is either while loops inside an if statement, or if statements inside a while loop.
First, the using namespace std; should be under the #includes and before main().
With loops it helps to step through on paper for different values. The two while loops have the same problem. Look...
The function is getch(), not getche(), unless there's one I don't know. The exercise probably calls for getche()so that the names don't conflict. You create the getche() function, and you don't use...
One difference is that the Learners Edition doesn't allow you to make release builds. That means you can't make an .exe file to distribute or sell.
I'd suggest searching previous posts. This thread seems to pop up about once every week or two. Plenty of suggestions there.
Frisky isn't the class, SimpleCat is. Frisky is an object, an instance of the class SimpleCat. Yes, every time you declare an instance, or object, of class SimpleCat, the constructor is called.
Pointers are used to call base class virtual functions in order to call the correct derived class function at run time rather than compile time.
cout << "Hit q then enter to quit." << endl;
displays quoted message on screen and, advances display one line, sets cursor to beginning of line
char input;
declares variable named input of type...
Don't hate to ask, that was the problem. Thanks. I was trying to get all the input on one line, e. g.
"enter tool name, quantity...", then enter sledge hammer 43 19.99 <enter>.
Do you know of a...
Well, that helps some, but still doesn't work quite right. When the program runs and asks for the user to enter tool name, quantity and cost, it hangs until any other character is entered. It also...
I'm having problems with files myself, but don't know if you can open an ifstream with ios::out. Never seen it, anyway.
That didn't work by itself, but adding two cin.ignore()'s helped:
if (tool.recNum == 0)
{
cout << "\nEnter tool name, quantity and cost: ";
cin.ignore();
cin.getline(tool.toolName,...
The whole function is below. toolName is a field in a struct named toolList.
I've done:
cin.getline(tool.toolName, 20) >> tool.quant >> tool.cost;
and
cin.getline(tool,toolName, 20);
cin >>...
The code below works in writing tool.toolName, tool.quant, and tool.cost into a file when toolName is one word ("hammer", e.g.). But it doesn't work when toolName is more than one word ("power...
lines++ // incremant the value contained in lines by 1. If lines == 16, lines++ sets lines to 17
lines++ % 20 // divide lines by 20 and find the remainder. If lines == 25, lines % 20 == 5.
...
Shouldn't that be delete [] pointer?
What does int ** mean? I've seen double asterisks a few places, but never an explanation of them.
I don't know enough C to help you, but it looks like half your program is commented out. I also don't see where you use the two structs you declared, PEOPLE and *field. Where does *member come from?...
try cout << number << " raised to the power " << power << endl;
As for a loop, what kind do you want? One that runs till the user ends it? one that loops a certain number of times?
Here's how I initialized 100 records of struct person.
struct person
{
char lastName[15];
char firstName[15];
char age[4];
};
.
Whether you use int main() or int main(void), you'll need to return, usually return 0;
As far as I know, you can't use main() or main (void), You can use void main()
What you might be thinking of is the this pointer, which you return in overloaded << or >> operator functions to allow cascaded returns, like input << x << y << z; etc.
the return is:
return this;...
If I'm reading you correctly, I did add that code to update in the post before yours. update doesn't hang now, but doesn't overwrite the old record with new data either. It doesn't do anything, as...
If you have an unmanageable number of variables in a class, your class is too big. Redesign it, maybe make base and derived classes or separate classes altogether. There's not a built in data type...