Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. char sir[256],c,*p;
  9. int nr=0;
  10. cout<<"sirul de caractere ";cin.get(sir,100);
  11. cout<<"Caracterul cautat ";cin>>c;
  12. cout<<"caracterul "<<c<<" apare in pozitiile: "<<endl;
  13. p=strchr(sir,c);
  14. while (p)
  15. {
  16. cout<<p-sir+1<<" ";nr++;p=strchr(p+1,c);
  17. }
  18. cout<<endl<<"apare in "<<nr<<" pozitii";
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement