0

It's not working ! Why ?

#include<iostream> using namespace std; int main(){ int v_space=500; int c[v_space],i; for(i=0; i<v_space; i++) c[i]=0; char str[100]; int str_ln; cout<<"enter the string \n"; cin>>str; str_ln=strlen(str); ///////////////////////////////////////////// for(i=0;i<str_ln;i++) c[str[i]]++; ///////////////////////////////////////////// cout<<"latters | used\n"; cout<<"---------------------------"; for(i=0;i<v_space;i++) if(c[i]!=0)

28th Dec 2016, 2:57 PM
Pankaj Devesh
Pankaj Devesh - avatar
9 Antworten
+ 2
Error is here: for(i=0;i<str_ln;i++) c[str[i]]++; You need to use a map instead of array.
28th Dec 2016, 3:08 PM
Vladimir Honcharenko
Vladimir Honcharenko - avatar
+ 2
Or change it to for(i=0; i<str_ln; i++) c[(int) str[i]]++; cout<<"letters \t|\t used\n"; cout<<"---------------------------"; for(i=0; i<v_space; i++) if(c[i] != 0) cout << (char) i <<"\t|\t "<< c[i] << endl;
28th Dec 2016, 3:22 PM
Vladimir Honcharenko
Vladimir Honcharenko - avatar
+ 1
create project in the playground, copy link and paste here
28th Dec 2016, 3:32 PM
Vladimir Honcharenko
Vladimir Honcharenko - avatar
28th Dec 2016, 3:52 PM
Vladimir Honcharenko
Vladimir Honcharenko - avatar
+ 1
lol, just create a new code and delete old one :)
28th Dec 2016, 4:30 PM
Vladimir Honcharenko
Vladimir Honcharenko - avatar
0
it is to count the friquancy of letters in string /*you can use it for any language keywoard the only need is to extend the virtual space(v_space) no need to remamber the ascii 😁 values of every language ....*/
28th Dec 2016, 3:03 PM
Pankaj Devesh
Pankaj Devesh - avatar
0
few lines are missing .....⬆️ due to word limit of questions.🤔
28th Dec 2016, 3:29 PM
Pankaj Devesh
Pankaj Devesh - avatar
0
I don't know how to do it 🙄
28th Dec 2016, 3:35 PM
Pankaj Devesh
Pankaj Devesh - avatar
0
the same code: https://code.sololearn.com/c537ntWq8H1f/?ref=app is still not working ..... I think the compiler have some personal animosity for me 😭
28th Dec 2016, 4:28 PM
Pankaj Devesh
Pankaj Devesh - avatar