View Single Post
Old Mar 30th, 2008, 1:12 PM   #1
Marijan
Newbie
 
Join Date: Feb 2008
Posts: 15
Rep Power: 0 Marijan is on a distinguished road
Got stuck while making a program,help would be appreciated

I decided to make a program that would change the inserted text according to this pattern:Replacing every letter with the next one in the alphabet.For example:
"Cat"- "Dbu".
I started and it went well up untill a point,my code looks like this so far:
c++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. void Funkcija1(string zbor)
  6. {
  7. char x;
  8. zbor[x];
  9. for(x=0;x<100;x++)
  10. {
  11. if(zbor[x]=='a')
  12. zbor[x]='b';
  13. }
  14.  
  15. cout<<zbor<<endl;
  16.  
  17. }
  18.  
  19. int main()
  20.  
  21. {
  22. string Vs;
  23. cin>>Vs;
  24. Funkcija1(Vs);
  25.  
  26. system("PAUSE");
  27.  
  28. return EXIT_SUCCESS;
  29.  
  30. }

It seemed to work well,but when i tried to make the program to replace the letter "B" with "C",it replaced the allready replaced letter "B".I am a tottal begginer in C++ and with no experience in other programming languages so far.
I found help some time ago here on another question,i sincerely hope that you guys will be helpfull again.
Marijan is offline   Reply With Quote