Need help with my code

Need help with my code. The programm is done in 90% or more, but doesn't work right. I don't know what to do, because I'm learning c++ for 3 months, but I have to do this work. Also I'm sorry for my English, I'm from Russia.

"The function overwrites the string. If it finds a number on the line, then instead of it it overwrites the corresponding word from the input line into the output line. (for example, "aaa bb1bb cc2cc" - "aaa bbaaabb ccbb1bbcc"). Repeat this process until there are no numbers left in the line. Check the possible loops when two words refer to each other."

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
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <conio.h>
void tekst(char c[], char d[])
{
            int i, j, k=0, b[20], n;
            for (i=0; c[i]!=0; i++) //Writes the indices of the beginnings of words. The cycle of recording the indices of the beginning of words.
            {
                       if (!(c[i]==' '))
                       {
                                  b[k++]=i;
                                  while (!(c[i]==' '|| c[i+1]==0))
                                            i++;
                       }
            }
            for (i=0, j=0; c[i]!=0; i++)
            {
                       if (c[i]>='0' && c[i]<='9')
                       {
                                  n=c[i]-'0';
                                  i++;
								  while (c[i]>='0' && c[i]<='9');} // Translating from char to int numbers. A cycle of translating a number from char [] to int.
                       else d[j++]=c[i]; // If there are no numbers in the word, overwrite it. The cycle of the creating a new array.
            }
            d[j]=0;
}
void main(){
setlocale(LC_ALL, "Russian");
char c[80],d[80];
int r;
          puts ("Введите строку слов: "); // Enter a string of words
          gets (c);
          tekst(c,d);
          for (r=0; d[r]!=0; r++)
                    if (d[r]>='0' && d[r]<='9') // If there are numbers, then run again
      tekst(d,c);
printf(c);
_getch();
}
There's a problem with the problem.

You have a single word: "a1".

You replace the 1 with the first word, giving "aa1".

You replace the 1 with the first word, giving "aaaa1".

You replace the 1 with the first word, giving "aaaaaaaa1".

There's a problem with the problem.
Topic archived. No new replies allowed.