I assume this is what you have now....
Code:
#include <stdio.h>
#include <conio.h>
int main() {
int num;
char lastname[1];
float tempnum;
float purchase[100];
do {
printf("Customer number: \n");
scanf("%d", &num);
printf("1st letter: \n");
getche();
lastname[1] = getche();
printf("Amount of purchase: \n");
scanf("%f", &tempnum);
purchase[100] = tempnum;
} while(num!= '0');
return 0;
}
The problem is here....
PHP Code:
printf("1st letter: \n");
getche();
lastname[1] = getche();
printf("Amount of purchase: \n");
The getche() function takes one keystroke from the keyboard and echoes the key pressed. In this case first getche(); takes the keystroke W (from your example) and then lastname[1]=getche(); waits for another keystroke. Which I am assuming is when you press the Enter Key, which is another keystroke which is echoed. So it's echoing a carriage return, but not a newline (or is it vice versa? I get confused on the 2 terms sometimes) which basically pushes the cursor back to the beginning of the line but does not step down to a new line. The following printf("Amount of purchase: \n"); then prints from that point. Causing the illusion of printing over the W.
Not only that, but the only thing stored in lastname[1] is the carriage return, not the letter you pressed. And it's beyond me why you're setting up a 1 character array. Just use a char type variable.
A simple solution (other than considering a complete rewrite) would be to lose the first getche() function call, and add a \n to the beginning of the printf's conversion string.
Consider using getchar() vs getche() (since getche isn't portable anyhoo).