home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!europa.asd.contel.com!emory!swrinde!cs.utexas.edu!sun-barr!sh.wide!wnoc-kyo!kuis!kudpc!nucc!f43703a
- From: f43703a@nucc.cc.nagoya-u.ac.jp (SUPRATIC GUPTA)
- Subject: HGelp needed - C++
- Message-ID: <1992Nov12.040531.5051@nucc.cc.nagoya-u.ac.jp>
- Organization: Nagoya University Computation Center, Nagoya, Japan.
- Date: Thu, 12 Nov 1992 04:05:31 GMT
- Lines: 71
-
-
- Dear friends,
- I am having a problem with C++, can you help me? Please answer
- to me directly.
-
- #include <stream.h>
- #include <stdio.h>
- #include<stdlib.h>
- #include <string.h>
-
- main(){
- char* objname[2];
- for(int i = 0; i < 3; ++i){
- objname[i] = "UNDEFINED";
- }
- char* ZZZ = " ";
- if(k == 0) ZZZ = "aaaaaaaaa";
- if(k == 1) ZZZ = "bbbbbbbbb";
- if(k == 2) ZZZ = "ccccccccc";
- for(i = 0; i < 3; ++i){
- cout <<"after " << i << " "<< objname[i] << endl;
- }
- objname[k] = ZZZ;
- }
- }
-
- The out put is OK It looks like this;
-
- 0 UNDEFINED 1 UNDEFINED 2 UNDEFINED
- 0 aaaaaaaaa 1 UNDEFINED 2 UNDEFINED
- 0 aaaaaaaaa 1 bbbbbbbbb 2 UNDEFINED
-
- But if I use this program;
-
- #include <stream.h>
- #include <stdio.h>
- #include<stdlib.h>
- #include <string.h>
-
- main(){
- char* objname[2];
- for(int i = 0; i < 3; ++i){
- objname[i] = "UNDEFINED";
- }
- char* ZZZ = " ";
- for(int k = 0; k < 3; ++k){
- cout << "INPUT > " cin >> ZZZ;
- for(i = 0; i < 3; ++i){
- cout << i << " "<< objname[i] << " ";
- }
- cout << " " << endl;
- objname[k] = ZZZ;
- }
- }
-
- The answer looks like this:
-
- INPUT > aaaaaaaaa
- 0 UNDEFINED 1 UNDEFINED 2 UNDEFINED
- INPUT > bbbbbbbbb
- 0 bbbbbbbbb 1 UNDEFINED 2 UNDEFINED
- INPUT > ccccccccc
- 0 ccccccccc 1 ccccccccc 2 UNDEFINED
-
- The answers are different, when the only difference is that in
- second case I am using "cin" for input. Can any one explain?
-
- with regards
- SUPRATIC GUPTA
-
-
-