De ce imi da eroare acolo:
#include <iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
char *s,c[100],aux[100];
int i,nr;
int main(){
s=new char[100];
cin.getline(s,100);
i=0;int j;
while(i<=strlen(s)-2)
{
nr=1;
j=i+1;
while(strcmp(s[i],s[j]))==0) /////////AICIIIIIIIIIIIIIIIII
{nr++;i++}
if(nr>1){itoa(nr,aux,10);
strcpy(c,"#");
strcpy(c,*(s+i));
strcpy(c,aux);}
else strcpy(c,*(s+i));
i++; }
c[strlen(c)+1]=NULL;
delete s;
cout<<c;
}

1

Răspunsuri

2014-05-18T23:32:27+03:00
Strcmp() compara doua SIRURI de caractere, tu compari doua ELEMENTE ale unui sir. Daca vrei sa vezi daca sunt acelasi caracter, compara codul ASCI transformandu-le in intregi . while(int(s[i])==int(s[j]){}