Witam!
Tworzę mały program zliczający ilość znaków w danym wierszu. Niestety, w trakcie kompilacji, dostaje błąd o treści no 'operator++(int)' declared for postfix '++' [-fpermissive] i nie za bardzo wiem jak sobie z tym poradzić.
Mój kod:
#include <iostream>
#include <string>
using namespace std;
void strcount(const string & str);
int main()
{
using namespace std;
string input;
string next;
cout << "Wprowadź wiersz:\n";
getline(cin, input);
while (cin)
{
getline(cin, next);
strcount(input);
cout << "Wprowadź następny wiersz:\n";
getline(cin, input);
}
cout << "Koniec\n";
return 0;
}
void strcount(const string & str)
{
using namespace std;
static int total = 0;
int count = 0;
cout << "\"" << str << "\" zawiera ";
while (str++)
count++;
total += count;
cout << count << " znaków\n";
cout << "Łącznie "<< total << " znaków\n";
}
Chodzi dokłanie o o tę kwestię "while (str++)".