guys this is where i got problem.I have written a programe using graphics..so i want to take passwords using asterik(*) .i have made a function to take inputs to avoid ESC pressed or ENTER pressed. when i take 1st input via getche() it write data in string but after 1st input when i take next input using this function it take inputs but did'nt write in string..here is the function...
I presume that you have just posted the function and not the whole program since there is no main() function.
The two biggest problems I can see with the code are:
1) You pass a char string of undefined length to the function and then attempt to access an arbitrary element within that array? You should define an array of a certain size and then pass a pointer to that array and the size of the array into the function.
2) You establish an infinite loop and then use 'goto' statements to get out of it (has no one ever told you that 'goto' statements are terrible programming practice? If not, then I am telling you now).
Instead of using 'goto' statements and infinite loops try doing something like this:
Also, a few tips for the future:
ch = getch();
/* Check for things like backspaces and new line characters (so you can NULL terminate your C-string) */
/* Put the character into the buffer */
} while( ( (ch != '\n')||(ch != '\r') )&&(i < str_len) );
1) When you submit code use code tags instead of posting your source code as a file - people are more inclined to read text from a web browser than they are to download a file and open it. If you don't know how to use code tags, read the sticky.
2) Make sure your code is properly indented. The code you posted is difficult to read because it is more difficult to pick out the beginning and end of loops, if statements, switch statements, functions etc.
3) More people will be willing to help you if you show time and care over your post. That means that you should try to formalise english and make your sentences more coherent. You can use slang and abbreviations but when describing your problem try to be as precise as possible.
4) Try to get your spelling right in both your post and your program. Spelling mistakes in either puts people off trying to help you because unless you show the appropriate level of care and consideration, what is the point?