input does not work properly
Hello guys
In the following code last input doesn't work
And the next line output prints some negative garbage value
why :confused:
thank you
Code:
// Test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include "conio.h"
int _tmain(void)
{
int sum= 0, val = 1 , a ;
while(std::cin >> val){
sum +=val;
++val;
}
std::cout << " Sum Of Entery are " << sum << std::endl;
std::cin >> a ;// does not take any value
std::cout<< a ;
_getch();
return 0;
}