April 21st, 2013, 11:58 PM
I'm stucked here.Please Help me.
I was writing code of simple Mono alphabetic substitution cipher and i got this error. I observed this kind of error previously and it was solved by "getch()" . But unfortunately i am unable to solve this with it. Can you guide me why i am not able to run it correctly at "Runtime" ?
Let me tell you about the error: When user enters the key value ,the "scanf" is skipped for every even times in while loop.Means User is able to enter key value for first time then second is skipped and third is printed.I don't know the reason behind this.Kindly some one enlighten me. :confused: :confused:
char * plainText;
printf("NOTE:The alphabet in key shuld be unique for all the Alphabets.\n");
while(*pointerOfAlphabet != NULL)
printf("Enter Value for:\"%c\"",*pointerOfAlphabet);
if(strchr(key,inputCharacter) == NULL)
printf("The input character is alredy inthe key.Inut other.");
April 22nd, 2013, 12:19 AM
You are telling scanf to read in the Enter key's code instead of skipping it. How else would you expect your program to behave if you tell it to do such things?
Now, if instead you were to do this,
, then you'd be telling scanf to expect white space to precede the character you're interested in and that it should skip that white space. Please note the space in front of the percent sign.
April 22nd, 2013, 01:33 AM
Thank you. I got your point.
Originally Posted by dwise1_aol
Closing this thread with this comment.