for ( i=0;i<a;i++ )
	{   
		
		qin.Echo();
		qin>>b; 
		if(b == (char)8) { total--;
		    cuv[i-2]=cuv[i-1];
			cuv[i-1]=0;
			i--;
		} else if(b!=char(13)){  // for key enter
				total++;
		space++;
		
			cuv[i]=b;  } else break;
		
		
	}

If pressed once or twice "backspace" works, but if pressed for more than two times, not working, first i checked for once "backspace" i make cuv[i-1]=cuv ; cuv=0;.. so i see for twice "backspace"... cuv[i-2]=cuv[i-1]; cuv[i-1]=0;... but i dont know how can i make this for more backspace.

ps: i dont want use strlen,or strchr;

Recommended Answers

All 2 Replies

I don't know what it is you're trying to do, but if i is less than 2 and "backspace" is pressed, you will try and access a negative index in the cuv array. This will definitely cause you a problem at some point.

for example if i write abcdefg and i press once"backspace", my array is abcdef;
if i press twice backspace my array is abcde .... but if i press more >=3 .. not work..
if you want , i can put all code.
Thank you !!!

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.