sup ?
i want to make "bbbnnnngg" into "3b4n2g", but this code dosnt working...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
using namespace std;
char mini(char *m) {
char *s = m, f[10];
int x = 1, y = 0;
while (*s) {
if (*s == *s++) {
x++;
s++;
}
else
{
f[y] = 'x';
y++;
f[y] = *s;
x = 1;
s++;
y++;
}
}
cout << f << endl;
return 0;
}
int main()
{
char str[10] = { "bbbnnnngg" };
cout << mini(&str[0]) << endl;
cin >> str;
return 0;
}
|
so what should i write instead? sorry.. im not that good with pointers...
thx
Topic archived. No new replies allowed.