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)
9 odpowiedzi
+ 2
Error is here:
for(i=0;i<str_ln;i++)
c[str[i]]++;
You need to use a map instead of array.
+ 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;
+ 1
create project in the playground, copy link and paste here
+ 1
a working code:
https://code.sololearn.com/c537ntWq8H1f/?ref=app
+ 1
lol, just create a new code and delete old one :)
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 ....*/
0
few lines are missing .....⬆️
due to word limit of questions.🤔
0
I don't know how to do it 🙄
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 😭