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;
}
#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;
}
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
char* CreateArrByNumber(int number, int* len)
{
*len = (int)log10((double)number) + 1;
char mas[10];
char* arr = mas;
int i;
for (i = *len - 1; i >= 0; --i)
{
*(arr + i) = '0' + (number % 10);
number /= 10;
}
return arr;
}
int main()
{
int i;
int len;
int number;
printf("number= ");
scanf_s("%i", &number);
if (number == 0)
{
printf("Input 0, error!");
}
else {
char* arr = CreateArrByNumber(number, &len);
for (i = 0; i < len; ++i)
printf(" %c", arr[i]);
return 0;
}
}