Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  int zoma(char* string)
  4.  {  int counter=0;
  5.      for (int i=0;string[i]!='\0';i++)
  6.      {
  7.          counter++;
  8.      }
  9.      return counter;
  10.  }
  11.  char* shecvla(char*string,char symbol,int pozicia)
  12.    {  
  13.      int size =zoma(string);
  14.          pozicia--;
  15.          cout <<" size "<< size <<endl;
  16.        if (pozicia>=0 && pozicia<=size)
  17.       {
  18.      
  19.        string[pozicia]=symbol;
  20.        
  21.        return string;
  22.          
  23.       }
  24.      
  25.        else
  26.        {  string="error out of range";
  27.            return string;
  28.        }
  29.            
  30.    }
  31. int main()
  32. {  
  33.     int pozicia;
  34.     char string[100];
  35.     char symbol;
  36.     cout<<"sheyvane stringi:";
  37.     cin>>string;
  38. cout <<" sheyvane symbolo: " ;
  39. cin>>symbol;
  40. cout<<"sheyvane pozicia chanacvlebis : ";
  41. cin>>pozicia;
  42.  
  43.  
  44.  char * changed=shecvla(string,symbol,pozicia);
  45.  
  46.      cout<<changed;
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement