C |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| #include <conio.h>
#include <stdio.h>
#include <string.h>
#define N 500
void main ()
{
char const str1[N]={"Computer \n programming \t is the process of designing, \nwriting the source code of computer \t programs"};
//char const enter[4]={"\\n"};
char* p;
int i, n=0;
clrscr();
printf("%s",str1);
n=strlen(str1);
char *str2 = new char [n];
str2 = strdup(str1);
for (p = str2; *p; ++p)
{
if (*p == '\n')
*p =* "\\n";
if (*p == '\t')
*p =* "\\t";
}
printf("\n\n%s\n",str2);
getch |
|
Вот что у меня получилось. появилась проблемка: нельзя заменить 1 символ на 3, плз кто понимает подправте