| | |
Tell Me Why It Happens!!!!!!!
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2004
Posts: 5
Reputation:
Solved Threads: 0
hello guys,
I came across a strange thing when doing program in c++ in visualc++ environment.just run this code and after entering the array elements press up arrow and down arrow.
Here's the code
#include<iostream.h>
void main()
{
int arr[5];
cout<<"Enter the array elements : "<<endl;
for(int i=0;i<5;i++)
cin>>arr[i];
cout<<"\n\n";
for(i=0;i<5;i++)
{
cout<<"The element no."<<i<<" is "; \\PRESS THE DIRECTION KEYS NOW
cin>>arr[i];
}
cout<<"\n\n";
}
I came across a strange thing when doing program in c++ in visualc++ environment.just run this code and after entering the array elements press up arrow and down arrow.
Here's the code
#include<iostream.h>
void main()
{
int arr[5];
cout<<"Enter the array elements : "<<endl;
for(int i=0;i<5;i++)
cin>>arr[i];
cout<<"\n\n";
for(i=0;i<5;i++)
{
cout<<"The element no."<<i<<" is "; \\PRESS THE DIRECTION KEYS NOW
cin>>arr[i];
}
cout<<"\n\n";
}
•
•
•
•
Originally Posted by prathys
I came across a strange thing when doing program in c++ in visualc++ environment.just run this code and after entering the array elements press up arrow and down arrow.
Or might you be marvelling at the command shell in which your code is running? (F7 is really cool, too!)
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
•
•
just run this code and after entering the array elements press up arrow and down arrow
But ur code just reminded me of a question that i always wanted to ask,
C++ Syntax (Toggle Plain Text)
for(int i=0;i<5;i++) cin>>arr[i];
C++ Syntax (Toggle Plain Text)
for(i=0;i<5;i++) { cout<<"The element no."<<i<<" is "; cin>>arr[i]; }
"He who mixes with people and endures the harm they do is better than he who does not mix and endures." (Tirmidhi)
•
•
•
•
Originally Posted by Asif_NSU
However, my Visual C++ doesnt produce any error and the program runs fine. Why is this so, why is this two compiler behaving differently. Has it not been standarized that i's scope is limited within the block of "for" loop?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
Join Date: Oct 2004
Posts: 5
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Dave Sinkula
Would you mind telling us what this "strange thing" was?
Or might you be marvelling at the command shell in which your code is running? (F7 is really cool, too!)
i am running my code in msvc++ 6.0
ya.the thing i wondered was.. it happens even after giving ignore() and clear() commnds.So it doe not matters with the buffer.So tell me how the previous input stays in that keys particularly?
Again, are you investigating your program or the shell in which it is running?
I am guessing that you are in Windows. I think you are confused by Doskey.
[edit]Go to "Command Prompt" and enter "help doskey". Is this the same behavior you see?
I am guessing that you are in Windows. I think you are confused by Doskey.
[edit]Go to "Command Prompt" and enter "help doskey". Is this the same behavior you see?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
•
•
Originally Posted by Asif_NSU
Strange, but i m using MS Visual C++ 6.0, too.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
To dave:
I was wondering why my MS visual c++ 6.0 is not pointing that out (the thing with i's scopes) as an error, but ur MSVC6 is. My friend's MSVC6 doesnt produce an error either. Since i do not expect u to know what is wrong with my particular compiler without seeing it for urself, i said "Strange, but i m using MS Visual C++ 6.0, too." Got it big bro?
I was wondering why my MS visual c++ 6.0 is not pointing that out (the thing with i's scopes) as an error, but ur MSVC6 is. My friend's MSVC6 doesnt produce an error either. Since i do not expect u to know what is wrong with my particular compiler without seeing it for urself, i said "Strange, but i m using MS Visual C++ 6.0, too." Got it big bro?
"He who mixes with people and endures the harm they do is better than he who does not mix and endures." (Tirmidhi)
•
•
•
•
Originally Posted by Asif_NSU
To dave:
I was wondering why my MS visual c++ 6.0 is not pointing that out (the thing with i's scopes) as an error, but ur MSVC6 is. My friend's MSVC6 doesnt produce an error either.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Other Threads in the C++ Forum
- Previous Thread: Narue ROCKS!!! but need one last thing???
- Next Thread: C++ Help Files
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






