Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Program only executing first input.

$
0
0
#include <conio.h>
#include <iostream>
#include <cctype>


int main()
{
	 char A, C, B, D;

	printf("Press a printable key >");
	scanf("%c", &A);
	printf("%c's integer equivalent is %d", A, (int) A);

	while(A != '#');
	
	printf("Press a printable key >");
	scanf("%c", &C);
	printf("%c's integer equivalent is %d\n", C, (int) C);

	while(C != '#');
	
	printf("Press a printable key >");
	scanf("%c", &B)/>/>/>;
	printf("%c's integer equivalent is %d", B, (int) B)/>/>/>;

	while(B != '#');

	printf("Press a printable key >");
	scanf("%c", &D);
	printf("%c's integer equivalent is %d", D, (int) D);
	
	while(D != '#');

	getch();
	return(0);
}


Haha me again :P/>/> So... this code kinda works... If I run it I can enter any keyboard character and get its correct ASCII code, but I can only do it once. It runs through the first printf()scanf()printf() then will go no further. I don't understand what is wrong with it to not proceed to the next printf() and let me enter another character.

Thanks for any help!

*** Edit ***
Please use code tags when posting code
:code:

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>