#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#define MAXSTR 128
void InputSymbol(char* Stri, char symbol);
int main() {
char s[MAXSTR], symbol;
printf("Input = \n");
gets(s, MAXSTR);
printf("Input symbol = \n");
scanf_s("%c", &symbol);
InputSymbol(s,symbol);
_getch();
return 0;
}
void InputSymbol(char* Stri, char symbol)
{
int n = strlen(Stri), i = 0, j = 0, k = 0;
char* r = (char*)malloc(2 * n);
for (i = 0; i < n; i++)
{
r[j++] = Stri[i];
k++;
if (k == 2)
{
r[j++] = symbol;
k = 0;
}
}
r[j] = '\0';
puts(r);
free(r);
}
InputSymbol(s, symbol);
, то получаю просто строку, которую ввожу, без модификаций.void InputSymbol(char* Stri, char symbol)
{
int n = strlen(Stri), i = 0, j = 0, k = 0;
char* r = (char*)malloc(2 * n);
for (i = 0; i < n; i++)
{
r[j++] = Stri[i];
k++;
if (k == 2)
{
r[j++] = symbol;
k = 0;
}
}
r[j] = '\0';
puts(Stri); //вывод строки
free(r);
}
InputSymbol(Stri, symbol));
void InputSymbol(char* Stri, char symbol);
int main() {
char s[MAXSTR], symbol;
printf("Input = \n");
gets(s, MAXSTR);
printf("Input symbol = \n");
scanf_s("%c", &symbol);
InputSymbol(Stri, symbol));
_getch();
return 0;
}
void InputSymbol(char* Stri, char symbol)
{
int n = strlen(Stri), i = 0, j = 0, k = 0;
char* r = (char*)malloc(2 * n);
for (i = 0; i < n; i++)
{
r[j++] = Stri[i];
k++;
if (k == 2)
{
r[j++] = symbol;
k = 0;
}
}
r[j] = '\0';
free(r);
}
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#define MAXSTR 128
int FindNum(char *, char *);
main()
{
const char enter = '\r';
int i = 0;
char s[MAXSTR], s1[MAXSTR];
printf("s=");
do s[i] = _getche(); while (s[i++] != enter);
s[i - 1] = '\0';
printf("\ns1=");
gets_s(s1, MAXSTR);
if (strlen(s1)) /* якщо підрядок не порожній */
printf("Sum total << %s >> =%i", s1, FindNum(s,s1));
else printf("Incorrect data!");
_getch();
return 0;
}
int FindNum(char *s_a, char *s_b)
{
int j = 0;
char *p = (char *)malloc(MAXSTR);
while (p = strstr(s_a, s_b))
{
printf("%i) ", ++j);
puts(p);
strcpy_s(s_a, MAXSTR, p + strlen(s_b));
}
free(p);
return j;
}
char* InputSymbol(char* Stri, char symbol)
{
int n = strlen(Stri), i = 0, j = 0, k = 0;
char* r = (char*)malloc(2 * n);
r[j] = '\0';
for (i = 0; i < n; i++)
{
r[j++] = Stri[i];
k++;
if (k == 2)
{
r[j++] = symbol;
k = 0;
}
}
return r;
free(r);
}
char* InputSymbol(char* Stri, char symbol)
{
int n = strlen(Stri), i = 0, j = 0, k = 0;
char* r = (char*)malloc(2 * n);
r[j] = '\0';
for (i = 0; i < n; i++)
{
r[j++] = Stri[i];
k++;
if (k == 2)
{
r[j++] = symbol;
k = 0;
}
}
free (r);
return r;
}
void Sort(double *data, unsigned int n)
{
double t, *pd1, *pd2;
for (pd1 = data; pd1 < data+n-1; pd1++)
for (pd2 = pd1 + 1; pd2 < data+n; pd2++)
if (*pd2 > *pd1)
{
t = *pd1;
*pd1 = *pd2;
*pd2 = t;
}
}
и for (i = 0; i < n - 1; i++)
for (j = 0; j < n - i - 1; j++)if (m[j+1] < m[j])
{
t = m[j];
m[j] = m[j+1];
m[j+1] = t;
}
void Sort(char* word, unsigned int length)
{
unsigned int i, j;
double t;
char* pointer = word;
/* алгоритм сортировки */
for (i = '-'; i <= 'z'; i++)
{
for (i = 0; i < length - 1; i++)
for (j = i + 1; j < length; j++)
if (*pointer == i)
{
*(result + d) = *pointer;
d++;
if (word[j] > word[i])
{
t = word[i];
word[i] = word[j];
word[j] = t;
}
}
pointer++;
}
pointer = word;
strcpy(word, t);
return pointer;
}