This never breaks
My problem is with the atoi function, it never detects a '0' being entered.Code:#include <iostream> #include <vector> #include <stdlib.h> #include <fstream> using namespace std; typedef vector<char*> CV; CV CharacterVector; ofstream fout; int main(void) { fout.open("crap.db"); int Number = 0; for( ; ; ) {{//stupid smily face arg CharacterVector.push_back(new char[50]); cout << "enter a character array "<< endl; cin.getline(CharacterVector[Number], 50); if(!atoi(CharacterVector[Number]) == 0) { cout << "You have chosen to quit" << endl; break; } else { fout << CharacterVector[Number] << endl; Number++; } }} fout.close(); return 0; }
This is kind of sad, I have been programming for a year now and I am still doing stupid stuff like this.
What are your opinions, do you think someone who has been programmign for a year should still be doing stupid stuff like this?



LinkBack URL
About LinkBacks



, but i have one piece of advice for you: adopt an indentation scheme and use it as you write whenever you write. it really doesn't take longer to write, and it makes your code easier to read and dissect and debug in the future, and you might think "i'm only writing this 20 line program", but what if you decide to reuse the code in something larger or simply want to refer back to it later?
Theres always someone better than you and always someone worse. I mean, I'm a 'newb' compared to the likes of adrianxw, sayeh, and the like, and yet I've been programming for about seven years.