Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <locale.h>
- #include <iostream>
- #include <stdlib.h>
- #include <string.h>
- using namespace std;
- int main()
- {
- setlocale(0, "russian");
- char** strs = new char* [30];
- for (int i = 0;i < 30;i++){
- strs[i] = new char [80];
- }
- char* ptr1;
- char* str = new char [80];
- printf("Введите строку,содержащую '*' :\n");
- int l = 0;
- gets(str);
- while(strlen(str) != 0){
- strcpy(*(strs + l++),str);
- gets(str);
- }
- char* s2=new char[80];
- for(int i = 0; i < l;i++) {
- char *c1 = strs[i];
- ptr1 = strs[i];
- printf("Адреса найденных символов '*' \n");
- while (*c1 != '\0') {
- if (*c1 == '*') {
- cout << *c1 << " " << (void *) c1 << " ";
- printf("\n");
- }
- c1++;
- }
- printf("Полученная строка,путем удвоения '*' :\n");
- while (ptr1 = strstr(ptr1, "*"), ptr1 != NULL) {
- strcpy(s2, ptr1);
- strcpy((ptr1 + 1), s2);
- ptr1 = ptr1 + 2;
- }
- puts(strs[i]);
- }
- for(int i = 0;i < l;i++){
- cout << strs[i] << endl;
- }
- for(int i = 0;i < l;i++){
- delete [] strs[i];
- }
- delete [] strs;
- delete[] s2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement