Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- int main()
- {
- char c[20];
- cout<<"Introdu sirul:"<<endl; cin.get(c, 20);
- char x;
- cout<<"Introdu caracterul"<<endl; cin>>x;
- char *p;
- p=strchr(c, x);
- int nrap=0;
- while (p){
- cout<<"Pozitia "<<p-c<<endl;
- nrap++;
- p=strchr(++p, x);
- }
- if (nrap) cout<<"Caracterul apare de "<<nrap<<" ori"<<endl;
- else cout<<" Caracterul nu apare"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement