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.
Looks like herold is doing C code as you said. Although the string header is in included but not used - so it's difficult to know what the real intention is.
@herold a couple number of things:
The name of a an array variable is implicitly converted to a pointer - so taking the address of it on line 8 & 11 isn't needed.
Line 10 looks like an error, the correct way to initialise an array specifies each char in single quotes separated by commas.
If you are going to do strings with pointers, you need to put the closing '\0' on the end manually with an assignment. So line 15 won't work unless you do this.
scanf returns a value which shows how successful it was. You should always test this value before using any variable it reads in - especially when reading more than 1, as sometimes only some of them might succeed. Remember you are dealing with a user that types at the console.
Same goes for any function that returns an error checking value. An example might be fprintf - I always use sprintf first - if that works as intended then use fprintf to send the string to the file. Always read the reference material for any function that you use.