Hallo ich habe hier ein kleines Problem, bin noch blutiger Anfänger in C++(gerade angefangen) und ich habe dieses Beispiel aus dem Primer, jedoch funktioniert es nicht so wie es sollte, da die Befehle nach der While-Schleife nicht ausgeführt werden.
Ich danke euch einmal für eure Hilfe :)
Code:
#include "stdafx.h"
#include <iostream>;
int main()
{
int currVal = 0, val = 0;
if(std::cin >> currVal)
{
int count = 1;
while(std::cin >> val)
{
if(val == currVal)
count++;
else
{
std::cout << currVal << " occurs "
<< count << " times " << std::endl;
currVal = val;
count = 1;
}
}
std::cout << currVal << " occurs " << count << " times " << std::endl;
}
return 0;
}