Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Solution1.cpp : Defines the entry point for the console application.
- #include "stdafx.h"
- #include <iostream>
- #include <conio.h>
- #include <string.h>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- char wyraz1[15]="01234567891234";
- char wyraz2[3]="ab";
- char* wyraz1N=new char[15];
- char* wyraz2N=new char[3];
- strcpy(wyraz1N, wyraz1);
- strcpy(wyraz2N, wyraz2);
- cout<<"Wyraz pierwszy: "<<wyraz1N<<endl<<endl;
- cout<<"Wyraz do wstawienia: "<<wyraz2N<<endl<<endl;
- int size1=strlen(wyraz1N);
- //cout<<endl<<size1;
- int size2=strlen(wyraz2N);
- //cout<<endl<<size2;
- char* bufor=new char[15];
- strcpy(bufor, wyraz1N);
- delete [] wyraz1N;
- wyraz1N=new char[size1+size2+1];
- size1=size1+size2+1;
- int n;
- cout<<"W jakim miejscu wstawic: ";
- cin>>n;
- cout<<endl;
- for(int i=0; i<n; i++)
- {
- wyraz1N[i]=bufor[i];
- }
- int j=0;
- for(int i=n; i<n+size2+1; i++)
- {
- wyraz1N[i]=wyraz2N[j];
- j++;
- }
- j=0;
- for(int i=n+size2; i<size1; i++)
- {
- wyraz1N[i]=bufor[n+j];
- j++;
- }
- cout<<endl<<endl<<wyraz1N;
- delete [] bufor;
- delete [] wyraz1N;
- delete [] wyraz2N;
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement