Hi all,

I am writing a program in which there is a part that computes all the possible values for two vectors of string patterns, one like 1XX78X9X32X (11 digit) the other like 26XX (4 digit), using digits from 0 to 9, and that passes all these possible strings to another two vectors.
So I wrote 16 nested for loops, the outer one for vector, the 15 inner ones for every digit of the patterns (11+4).
But for some reason the loop is infinite and it never terminates. I could not discover why.
I would really appreciate it if you have any ideas and can help me, it is really urgent.

Thanks in advance..

for(int x=0; x<namevect.size(); x++){

for(int a=0;a<=9;a++){

    	if(idpvect[x][0]=='X'){
      	idpvect[x][0]=intToChar(a);
		
    	}
for(int b=0;b<=9;b++){

    	if(idpvect[x][1]=='X'){
      	idpvect[x][1]=intToChar(b);
		
    	}
for(int c=0;c<=9;c++){

    	if(idpvect[x][2]=='X'){
      	idpvect[x][2]=intToChar(c);
		
    	}
for(int d=0;d<=9;d++){

    	if(idpvect[x][3]=='X'){
      	idpvect[x][3]=intToChar(d);
		
    	}
for(int e=0;e<=9;e++){

    	if(idpvect[x][4]=='X'){
      	idpvect[x][4]=intToChar(e);
		
    	}
for(int f=0;f<=9;f++){

    	if(idpvect[x][5]=='X'){
      	idpvect[x][5]=intToChar(f);
		
    	}
for(int g=0;g<=9;g++){

    	if(idpvect[x][6]=='X'){
      	idpvect[x][6]=intToChar(g);
		
    	}
for(int h=0;h<=9;h++){

    	if(idpvect[x][7]=='X'){
      	idpvect[x][7]=intToChar(h);
		
    	}
for(int i=0;i<=9;i++){

    	if(idpvect[x][8]=='X'){
      	idpvect[x][8]=intToChar(i);
		
    	}
for(int j=0;j<=9;j++){

    	if(idpvect[x][9]=='X'){
      	idpvect[x][9]=intToChar(j);
		
    	}
for(int k=0;k<=9;k++){

    	if(idpvect[x][10]=='X'){
      	idpvect[x][10]=intToChar(k);
		
    	}
for(int l=0;l<=9;l++){

    	if(idpvect[x][10]=='X'){
      	idpvect[x][10]=intToChar(l);
		
    	}
for(int m=0;m<=9;m++){

    	if(idpvect[x][10]=='X'){
      	idpvect[x][10]=intToChar(m);
		
    	}
for(int n=0;n<=9;n++){

    	if(bypvect[x][0]=='X'){
      	bypvect[x][0]=intToChar(n);
		
    	}
for(int o=0;o<=9;o++){

    	if(bypvect[x][1]=='X'){
      	bypvect[x][1]=intToChar(o);
		
    	}
}}}}}}}}}}}}}}}}
WaltP commented: Nothing is ever *urgent* -- stating so generally makes most people that can help completely ignore your thread. -3

Why not just make a loop over the index instead of having a separate explicit loop for each index?

Your inner loops run 205,891,132,094,649 iterations per outer loop. It's not infinite, but it might as well be. You need to reconsider what you are doing as you won't live long enough to generate all possible values for just one iteration of your outer loop.

commented: +rep for actually calculating the number of iterations. I'll take your word for it :) +13
commented: Must have taken a while to get the exact number +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.