Question about continue

Question in source code as comment
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<iostream>
#include<cstring>

using namespace std;

void char_permutation(char str[],char append[])
{
int length = strlen(str);
if (length)
{
for(int i=0;i<length;++i)
{
char* str1 = new char[length+1];
int cnt;
int cnt2;
for(cnt=0,cnt2=0; cnt<length; ++cnt,++cnt2)
{
if (cnt == i)
{
str1[cnt] = str[++cnt2];
continue;                         // Is this continue necessery here does it make a difference?
}
else
str1[cnt] = str[cnt2];
}
str1[cnt] = '\0';

int alength = strlen(append);
char* append1 = new char [alength+2];
strncpy(append1,append,alength);
append1[alength] = str[i];
append1[alength+1] = '\0';

char_permutation(str1,append1); 
delete []str1;              
delete []append1;
}
}
else
{
cout << append << endl;
}
}


int main()
{
char str[] = "BUSHES";

char append[] = "\0";

cout << "Original = " << str << endl;
char_permutation(str,append);
cout << "Done ........" << endl;

system("PAUSE");
return 0;
}

continue; // Is this continue necessery here does it make a difference?
It will make the loop going to the next iteration skipping the rest of the code present on the current iteration, after the continue call.
- You should indent that code -
Topic archived. No new replies allowed.