Message-ID: <38A94948.4985420D@earthlink.net> From: Martin Ambuhl Organization: Nocturnal Aviation X-Mailer: Mozilla 4.7 [en] (Win95; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Vector problem References: <20000214230117 DOT 03930 DOT 00001183 AT ng-ce1 DOT aol DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 98 NNTP-Posting-Host: 209.246.74.122 X-Complaints-To: abuse AT earthlink DOT net X-Trace: newsread2.prod.itd.earthlink.net 950618424 209.246.74.122 (Tue, 15 Feb 2000 04:40:24 PST) NNTP-Posting-Date: Tue, 15 Feb 2000 04:40:24 PST X-ELN-Date: Tue Feb 15 04:40:24 2000 Date: Tue, 15 Feb 2000 12:40:24 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com KNGARU wrote: > > sort of . . . > This doesn't work, granted there may be some problems to it, but I keep getting > errors I have no clue what to do with. > Here's the program: This does NOT fix the fact that this is a very bad way to accomplish your goal. Nor does it fix your possible overrun of the vector. It does, however, give you working C++ code. ** changes ** 1,3c1,3 < #include < #include < #include --- > #include > #include > #include 8c8 < int k; // counter --- > int k = 0; // counter 17,19c17,19 < cout << word << endl; // SHOULD OUTPUT THE VECTOR < < EXIT_SUCCESS; // stdlib.h --- > for (char *k = word.begin(); k < word.end(); k++) > cout << *k << endl; // SHOULD OUTPUT THE VECTOR > return 0; ** resulting code ** #include #include #include int main() { vector < char >word(10); // ten letter word int k = 0; // counter char letter; // no need while (cin >> letter) // input letter by letter . . . one step at a // time { word[k] = letter; // puts the letter in the current index of // the vector k++; // increases counter } for (char *k = word.begin(); k < word.end(); k++) cout << *k << endl; // SHOULD OUTPUT THE VECTOR return 0; } > #include > #include > #include > > int main() > { > vector word(10); //ten letter word > int k; //counter > char letter; //no need > while(cin>>letter) //input letter by letter . . . one step at a time > { > word[k]=letter; //puts the letter in the current index of the vector > k++; //increases counter > } > cout< > EXIT_SUCCESS; //stdlib.h > } > > I compile using the gxx command at the dos prompt . . . won't work any other > way, and get a whole lot of iostream errors. there are too many and they are > too long to try and make sense of. My "hello world"1 programs work with no > problems. This is just a small test . . . numbers don't work either. -- Martin Ambuhl mambuhl AT earthlink DOT net What one knows is, in youth, of little moment; they know enough who know how to learn. - Henry Adams A thick skin is a gift from God. - Konrad Adenauer __________________________________________________________ Fight spam now! Get your free anti-spam service: http://www.brightmail.com