std::string someString;
while(someString != "black"){
while(!(std::cin >> someString)) /*Deal with error*/;
std::cout << "1";
}
Type: Posts; User: ex-mortis
std::string someString;
while(someString != "black"){
while(!(std::cin >> someString)) /*Deal with error*/;
std::cout << "1";
}
Yeah, I know. I was only testing initial configurations for sequences I am familiar with. I have the simplelife iPhone app and I also checked a web-based Game of Life and when I said nothing was ...
Well that's embarrassing. My original copy function was "copy this to this" whereas this one is "copy to this from this". It works perfectly now, though I have a lot more work to do (UI-wise). Thanks...
Excellent suggestions, my program is considerably more efficient. Although I tried at first to pass in the arrays as function parameters I couldn't get it to work. Never thought of using a typedef.
...
1. I'm not? What is the proper way to check for an overrun then?
2. I already tried it, it doesn't work. The error is definitely in the conditionals because they return false or don't run at all...
Sorry, that's not what I was trying to say. I simply commented erroneously that it wasn't a problem but that I was going to fix it. Is this adequate enough?
// Scan adjacent cells for life
int...
Makes sense now that I think about it. Thanks for the tips, I'll get to work.
Nope. See for yourself.
Can you elaborate? I don't really understand.
Hadn't considered it. At the moment I'm only testing the middle of the board so it isn't a problem, but I'll fix it.
Sorry. The Game of Life is a non-interactive "game" that is "played" on a grid with any number of cells (in my program it's 25x25). Each cell can either be "dead" or "alive" and the game has four...
#include <iostream>
#include <cstdlib>
#include <Windows.h>
char grid[25][25];
void turnOn(int x, int y);
void turnOff(int x, int y);
bool lhmt3(int x, int y);
bool lh2o3(int x, int y);
Nice spot. It's a little carry-over from my char array design that I forgot to fix actually. Although what it does at the moment isn't catastrophic having a copy is pretty much unnecessary. Thanks.
Got it work just in case somebody else out there has a similar problem. This is the final loadGames() function:
void loadGames(){
std::string line, num_holder, title_holder, hours_holder;
...
Well, I'm sorry. "At first I tried to read directly into an int, std::string and double with no luck so I tried reading into character arrays and converting them to ints and std::strings with even...
Like I said, I am not sure what types of variables to declare because I haven't found a method that works yet and so I omitted the declarations.
Right now this code is completely...
void loadGames(){
std::ifstream load("Gamelist.gl");
num_holder;
title_holder;
hours_holder;
load.getline(num_holder, 1, ' ');
load.getline(title_holder, 20, ' ');
...
I just read through the "Why does my program enter an infinite loop if the user inputs invalid data?" entry that was linked to me and was better able to understand it now than before. So, now my...
I'm not just trying random stuff until something works, I just don't have a clue how cin works yet (though I have a vague idea now). This is actually the first program I've written in several weeks...
Well seeing as I don't know how to use exceptions I went back to the if statement method (which is what I tried to do first anyway and failed). It looks like this:
int x;
if...
So I shouldn't check for errors? Passing a string into std::cin >> *int* yields weird behavior. What I want is to reject all types save for integers. How would I go about that? I've tried catching a...
#include <iostream>
#include <fstream>
#include "MoneyManagement.h"
int main ()
{
std::ifstream iMoney("money.txt");
if(!iMoney){
std::cout<< "Error opening file.\n\n";
Awesome, I get it. Thanks everyone.
What is the "Bridge" pattern?
Yeah, that makes sense. Still, it doesn't answer my question regarding the use of the pimpl idiom. Why is it necessary exactly?
Ah, I understand now. But how does using a pointer to implementation help compilation dependency? It seems to me that if the implementation is located within the class, and the data members are safe...
How is it the same, exactly? I mean, assume we are just talking about int x = 9 and then later you change it to int x = 8. Hasn't the implementation changed? The pointer may remain constant, but...
So, I just read through Item 31 in Effective C++ and it confused the hell out of me. The idea is to minimize compilation on the client's part and I get why it's desirable, but I just don't see how...